Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sql question
select mid, count(*), sum(decode(code,'0',1,0)) zeros
from tab
group by mid
share and enjoy
uncle tzad's house o' SQL
>
> I have a table with the following structure:
>
> Table1
>
> mid(num), code(char)
> 1 A
> 1 A
> 2 0
> 2 A
> 2 C
> 3 A
> 3 A
> 3 0
> 3 B
> 3 0
>
> In which I want to list out the number of record for distinct mid and the
> occurrance particular character in code. Hence,
>
> count(*) group by mid mid instance of '0'
> 2 1 0
> 3 1 1
> 5 1 2
>
> I know how to produce the result with two individual sql statements. But any
> body can tell how to consolidate it by a single query.
>
> Please help
> thanks
> Elton
>
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Fri Jun 05 1998 - 08:22:38 CDT
![]() |
![]() |