Home » SQL & PL/SQL » SQL & PL/SQL » CASE and Group by
CASE and Group by [message #19455] Tue, 19 March 2002 10:32 Go to next message
uma
Messages: 67
Registered: May 2001
Member
I have a condition to verify and I want to group by for some fields. My query is like this

Select
product_id,
type_id,
case(when product_type!=2 then
sum(amount * quantity* rate)
else 0) amount

from Product
group by
product_id,
type_id,
case(when product_type!=2 then
sum(amount * quantity* rate)
else 0)

Can I use CASE in the group by ? I don't think so, in that case what I need to use in the group by clause. Is that product_type should be in the group by? I am puzzled, please help me.

Thanks,

Uma
Re: CASE and Group by [message #19456 is a reply to message #19455] Tue, 19 March 2002 10:55 Go to previous message
uma
Messages: 67
Registered: May 2001
Member
I think if I add product_type in my group by clause in stead of the whole case statment , it is woking. I hop e that is right.

Thanks,

Uma
Previous Topic: Oracle 8i Problem solving cases
Next Topic: Unique constraint
Goto Forum:
  


Current Time: Thu Apr 25 02:14:41 CDT 2024