Hi,
I HAVE 3 fields, CUSTOMER_ID, COLOUR and price
CUSTOMER_ID COLOUR price
1 RED 13
1 BLUE 23
2 YELLOW 4
2 BLUE 54
2 RED 35
ETC.
I have a group by cutomer_id and want to return for that customer a flag to say if they chose a particular colour (say RED)
I can do max(colour) as an aggregate function, but that doesn't help me.
How can I say 'if colours for this customer includes 'red' then 1 AS chose_red.
something along the lines of....(but that will work)
select customer_id, avg(price),max(colour),min(colour),case when colour includes 'red' then 1 else o end as chose_red
group by customer_id
I HAVE 3 fields, CUSTOMER_ID, COLOUR and price
CUSTOMER_ID COLOUR price
1 RED 13
1 BLUE 23
2 YELLOW 4
2 BLUE 54
2 RED 35
ETC.
I have a group by cutomer_id and want to return for that customer a flag to say if they chose a particular colour (say RED)
I can do max(colour) as an aggregate function, but that doesn't help me.
How can I say 'if colours for this customer includes 'red' then 1 AS chose_red.
something along the lines of....(but that will work)
select customer_id, avg(price),max(colour),min(colour),case when colour includes 'red' then 1 else o end as chose_red
group by customer_id