I have been given an interesting challenge by my boss. We have a dataset to extract certain advertisers on a page but if you are an advertiser who is logged in, he wants to make sure that persons ad shows first. Here is the script as it stand right now:
SELECT TOP 15
a.MemberID, -- 0
a.UserName, -- 1
a.MemberDisplayName, -- 2
a.NYKABizName -- 3
FROM Member a
INNER JOIN AdDisplay b ON b.MemberID = a.MemberID
WHERE a.Claimed = 'Y'
AND a.NYKACatID IS NOT NULL
AND b.LocalPageID = @LocalPageID
AND a.SBIcon = 'N'
AND a.Viewable = 'Y'
AND a.ProfileTypeID <> 1
AND a.PackageType <> 'G'
AND a.PackageType <> 'P'
AND a.PackageType <> 'C'
ORDER BY PackageType ASC
I want to add some like Include MemberID = 102. How can I change this script to accomplish the bosses wishes.
Many thanks in advance,
neojakey
Assuming that the query returns the advertiser in question (without the top 15), you can do this my modifying the order by clause:
This orders the list putting the desired member first, followed by everything else. You can still keep the top 15 in the query.