lundi 23 novembre 2020

sql query for sum count if

i need to use excel formula into my coding. the excel formula is like this =SUM(COUNTIFS(Table14[KUMP.],"PT",Table14[TARAF JAWATAN],{"TETAP (P)";"TETAP"},Table14[STATUS],"AKTIF")) and my coding in my codeigniter is like this $query = $this->db->query("SELECT SUM((count() as total,status FROM stafs where status = '1'), (COUNT() as total, kumpulan_perkhidmatan from 'stafs' WHERE kumpulan_perkhidmatan = '1'), (COUNT(*) as total, taraf_jawatan_sekarang FROM 'stafs' where taraf_jawatan_sekarang = '1' OR taraf_jawatan_sekarang = '2')); return $query->result();

Aucun commentaire:

Enregistrer un commentaire