HiPlease see the following select statement from a procedure that grabs data from 2 table variables and joins with some other actual tables:DECLARE @hideExpired BITSET @hideExpired = 0SELECT u.userID, u2.[name], u2.surname, ca.[level], ca.expiryDateFROM @tbl_userIDs u CROSS JOIN @tbl_linkIDs l INNER JOIN [tbl_SGS] sgs ON l.linkID = sgs.linkID LEFT OUTER JOIN [tbl_CA] ca on ca.userid = u.userid AND ca.sid = sgs.sid AND ca.sgid = sgs.sgid
Can anyone show me how to expand the above statement to include the following logic:When @hideExpired=1 If ca.expiryDate <= getUTCDate() Then ca.level displays as NULL If ca.expiryDate > getUTCDate() Then show ca.level valueWhen @hideExpired=0 No date comparison should take place - just return ca.level value
Thank you very much in advance.