Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Bill13
Starting Member
2 Posts |
Posted - 2009-03-01 : 19:39:59
|
let supose i have a table OPcolumns are order_id,cust_name,order_date,order_qty,products and my products are jeans,jacket,shirt,capnow i wanna write a query to find those customers who have purchased shirt but with shirt they have purchased something else too like a customer who purchased shirt + jeans but i dont wanna see shirt in result select order_id,customer_name,productsfrom opwhere products in ('jeans','jacket','shirt','cap')and ??????????? how can i remove shirts in results but i wanna see those customers who bought shirts plus some other thingsthanx |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-03-01 : 20:59:03
|
| select op.order_id,op.customer_name,op.productsfrom opjoin (select distinct order_id from op group by order_id having sum(case when products = 'shirt' then 1 else 0 end) > 0 and count(distinct products) > 1) aon a.order_id = op.order_idwhere products <> 'shirt'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|