Re: Using Single Query with Group by clause.

From: Brian E Dick <bdick_at_cox.net>
Date: Fri, 20 Dec 2002 21:53:59 GMT
Message-ID: <XjMM9.29469$pe.1028001_at_news2.east.cox.net>


The union would work. And it's not that difficult.

It's late on Friday and I'm taking my kids out to pizza.

"Srinivas" <skandu_at_yahoo.com> wrote in message news:c6a7eae9.0212201049.79508906_at_posting.google.com...
> Let's say there are four records in ks_temp
>
> insert into ks_temp values ( 10, 1000)
> insert into ks_temp values ( 20, 2000)
> insert into ks_temp values ( 20, 3000)
> insert into ks_temp values ( 20, 4000)
>
>
> If customer_id in where clause is 10, then I want 1 , 1000 as output.
> ( here 1 is the count of orders for the customer, 1000 is the order_id
> )
>
> If customer_id in where clause is 20, then I want 3 , -99999 as
> output. ( here 3 is the count of orders for the customer, -99999 is
> any random number )
>
> If customer_id in where clause is 50, then I want 0 , 0 as output. (
> here 0 is the count of orders for the customer, 0 is indicating 0
> orders )
>
>
> I am not sure if union can be used as suggested because it would
> return incorrect count.
Received on Fri Dec 20 2002 - 22:53:59 CET

Original text of this message