Peter Nordberg
asked on
Change sql statement depending on value
Hi,
I have an sql query looking like this:
Now I would like to expand the query by adding a WHERE clause. But I would like to alter the where clause depending of the subscriptionTypeID. So, for example, if subscriptionTypeID = 1 then the query would look like this:
and if subscriptionTypeID = 2 then
How can I achieve this scenario?
Thanks for help!
Peter
I have an sql query looking like this:
SELECT cm.ClubMemberID, cm.subscriptionTypeID FROM dbo.ClubMember AS cm
Now I would like to expand the query by adding a WHERE clause. But I would like to alter the where clause depending of the subscriptionTypeID. So, for example, if subscriptionTypeID = 1 then the query would look like this:
SELECT cm.ClubMemberID, cm.subscriptionTypeID FROM dbo.ClubMember AS cm
WHERE cm.Stopdate > '2018-01-01'
and if subscriptionTypeID = 2 then
SELECT cm.ClubMemberID, cm.subscriptionTypeID FROM dbo.ClubMember AS cm
WHERE cm.Stopdate < '2018-01-01'
How can I achieve this scenario?
Thanks for help!
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window