am Fri, dem 02.02.2007, um 13:09:09 +0530 mailte Shyju Narayanan folgendes: > Hi All > > > BUT I NEED THE RESULT AS > entry_user_id_int COUNT(VC) COUNT(VE) COUNT(CV) COUNT(SC) TOTAL > 78 1 1 8 1 11 >
You need something like this (i called the table foo and without the sc-column): select entry_user_id_int, sum(case when category_id_chv = 'VC' then 1 else 0 end) as "count(vc)", sum(case when category_id_chv = 'VE' then 1 else 0 end), sum(case when category_id_chv = 'CV' then 1 else 0 end), sum(1) from foo where entry_user_id_int = 78 group by entry_user_id_int; entry_user_id_int | count(vc) | sum | sum | sum -------------------+-----------+-----+-----+----- 78 | 1 | 1 | 8 | 11 Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster