sql server 2008 - SQL - Return results of row data -
so have following table (see below) , i'd write query return me game numbers have following in 3 ticket columns.
e.g. give me game numbers have 1,2 , 3 in them.
the numbers don't have in columns (like 1 in ticket1 etc...). have in game's row.
i'd post have of query far it's useless , need fresh pair of eyes see if possible , if so, how?
cross apply conditional count union of tickets.
select * mytable cross apply ( select count(case when ticket in (1,2,3) ticket end) cnt ( select ticket1 ticket union select ticket2 ticket union select ticket3 ticket ) t ) t t.cnt = 3
Comments
Post a Comment