Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql question

Re: sql question

From: <tzadkiel_at_surfnetcity.com.au>
Date: Fri, 05 Jun 1998 13:22:38 GMT
Message-ID: <6l8ret$o84$1@nnrp1.dejanews.com>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US