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

Home -> Community -> Usenet -> c.d.o.tools -> Re: help! In over my head

Re: help! In over my head

From: Jay Weiland <jay_at_pixar.com>
Date: Fri, 15 Dec 2000 13:17:12 -0800
Message-ID: <3A3A8A58.A8313C4A@pixar.com>

Hey Turk,

     You don't need to concatenate the fields if you don't want to...

select field1, field2, count(*)
from my_table
group by field1, field2;

...but the only reason I would go this route is if this query became part of a larger select statement and indexing was needed.

Jay!!!

TurkBear wrote:

> Try this:
>
> Select field1||field2 combo,count(*) from table_name
> group by field1||field2;
>
> ( The || is Oracle's concatenation operator - 2 vertical bars)
>
> Hope it helps...
> Check out any Oracle books by Kevin Loney...
>
> Bob McConnell <bob.mcconnell_at_mci.com> wrote:
>
> >Help!
> > How can I count the number of occurrances of data from 2 fields?
> >
> >I have a table like this:
> >field1 field2
> >a b
> >a c
> >a b
> >a d
> >a c
> >b a
> >b c
> >b a
> >
> >And would like to get results that indicate a count for the combination
> >of the 2 fields
> >
> >a b 2
> >a c 2
> >a d 1
> >b a 2
> >b c 1
> >
> >Also are there any good books on doing more complicated query design?
> >
> >thanks,
> >Bob

--
Received on Fri Dec 15 2000 - 15:17:12 CST

Original text of this message

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