Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

select record based on condition in sql

$
0
0

Hello all, 

i have the following data in table 

ID    event 

1xmas
1promo
2xmas
2promo
2promo
3xmas


 requirement is 

1) if ID with event has one xmas and one promo  we have to ignore that records

2) if ID with event has one xmas and multiple promo i have to ignore multiple promo records and show only ID with xmas record

3) if ID with event has only xmas without promos i have to show that record.

Result should be like this from above table 

when i select the data i need only

ID  EVENT

2    XMAS

3   XMAS

Please help me how can i solve thiss

Thanks in advance


Viewing all articles
Browse latest Browse all 7129

Trending Articles