Обсуждение: How to get Rows Count

Поиск
Список
Период
Сортировка

How to get Rows Count

От
Abdul Wahab Dahalan
Дата:
>
>
>a       b      d    c  
>01      02     b    *  
>01      02     a    *  
>02      03       
>02      04     b    *  
>02      04     a    *  
>03      05  
>04      06  
>
If I've a table like above, how do I make a query to get rows count that 
doesnt have '*' in it.

Can we have other queries than this : Select count(c) from tablename 
where c !='*';
or Select count(c) from tablename where c <> '*';




Re: How to get Rows Count

От
"Iain"
Дата:
howabout:

select sum(case when c =  '*' then 0 else 1 end) as count_not_star from
tablename

If you want to process all records but only count thouse without a * in c
then this will do the trick.

regards
iain
----- Original Message ----- 
From: "Abdul Wahab Dahalan" <wahab@mimos.my>
To: <pgsql-sql@postgresql.org>
Sent: Monday, March 01, 2004 11:06 AM
Subject: [SQL] How to get Rows Count


> >
> >
> >a       b      d    c
> >01      02     b    *
> >01      02     a    *
> >02      03
> >02      04     b    *
> >02      04     a    *
> >03      05
> >04      06
> >
> If I've a table like above, how do I make a query to get rows count that
> doesnt have '*' in it.
>
> Can we have other queries than this : Select count(c) from tablename
> where c !='*';
> or Select count(c) from tablename where c <> '*';
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)