sql - Two COUNT to one SELECT -


can tell me how can these 2 count 1 select please?

/*pocet treninku ucast*/ select jmeno, count(ucast) hraci  inner join ucast_trenink2 on ucast_trenink2.id_hrace_ucast=hraci.idhrace  inner join seznam_treninku on seznam_treninku.id_treninku=ucast_trenink2.id_treninku_ucast  inner join kategorie on kategorie.idkategorie=seznam_treninku.kategorie  (ucast='true')and(kategorie.idkategorie = 1) , datum >= '1/1/2013' , datum < '9/1/2014' group jmeno; /*pocet treninku neucast*/ select jmeno, count(ucast) hraci  inner join ucast_trenink2 on ucast_trenink2.id_hrace_ucast=hraci.idhrace  inner join seznam_treninku on seznam_treninku.id_treninku=ucast_trenink2.id_treninku_ucast  inner join kategorie on kategorie.idkategorie=seznam_treninku.kategorie  (ucast='false')and(kategorie.idkategorie = 1) , datum >= '1/1/2013' , datum < '9/1/2014' group jmeno; 

thanks lot

you can use this:

select     jmeno,     sum(case when ucast = 'false' 1 end) count_false,     sum(case when ucast = 'true' 1 end) count_true ... (kategorie.idkategorie = 1) , datum >= '1/1/2013' , datum < '9/1/2014' group jmeno; 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -