A
AJ
Folllowing on from a previous post, i have created a stored query as follows.
SELECT
c.ID, c.Company_Name, p.[level], 1 As QueryNbr
FROM
(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)
LEFT JOIN
Package AS p ON s.Package_ID = p.ID
WHERE
c.Category = 'EXH'
AND
(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))
AND
EXISTS(SELECT Company_ID FROM Event_Company_Link WHERE Event_ID =
@EventID AND Company_ID = c.ID)
AND
(INT(Start_Date) <= @StartDate) AND (INT(End_Date) >= @EndDate)
ORDER BY
p.[level] DESC , c.Company_Name, c.ID
UNION
SELECT
c.ID, c.Company_Name, p.[level], 2 As QueryNbr
FROM
(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)
LEFT JOIN
Package AS p ON s.Package_ID = p.ID
WHERE
c.Category = 'EXH'
AND
(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))
AND
EXISTS(SELECT Company_ID FROM Event_Company_Link WHERE Event_ID
=@EventID AND Company_ID = c.ID)
ORDER BY
c.Company_Name, c.ID
I want use the results from the preceding query in the following way:
SELECT
ID, Company_Name, level, QueryNbr
FROM
ExhibitorsSearchByName
//this query requires three parameters, Start_Date, End_Date, Event_ID
GROUP BY
ID, First(Company_Name), First(level), First(QueryNbr)
WHERE
Company_Name LIKE '%myCriteria'
What would be the best way to execute the previous query in ASP, including
sending the appropriate parameters???
Sample code would be great!
Cheers,
Adam
SELECT
c.ID, c.Company_Name, p.[level], 1 As QueryNbr
FROM
(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)
LEFT JOIN
Package AS p ON s.Package_ID = p.ID
WHERE
c.Category = 'EXH'
AND
(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))
AND
EXISTS(SELECT Company_ID FROM Event_Company_Link WHERE Event_ID =
@EventID AND Company_ID = c.ID)
AND
(INT(Start_Date) <= @StartDate) AND (INT(End_Date) >= @EndDate)
ORDER BY
p.[level] DESC , c.Company_Name, c.ID
UNION
SELECT
c.ID, c.Company_Name, p.[level], 2 As QueryNbr
FROM
(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)
LEFT JOIN
Package AS p ON s.Package_ID = p.ID
WHERE
c.Category = 'EXH'
AND
(s.ID = (SELECT Max(ID) FROM Sale WHERE Company_ID = c.ID) Or
IsNull(s.ID))
AND
EXISTS(SELECT Company_ID FROM Event_Company_Link WHERE Event_ID
=@EventID AND Company_ID = c.ID)
ORDER BY
c.Company_Name, c.ID
I want use the results from the preceding query in the following way:
SELECT
ID, Company_Name, level, QueryNbr
FROM
ExhibitorsSearchByName
//this query requires three parameters, Start_Date, End_Date, Event_ID
GROUP BY
ID, First(Company_Name), First(level), First(QueryNbr)
WHERE
Company_Name LIKE '%myCriteria'
What would be the best way to execute the previous query in ASP, including
sending the appropriate parameters???
Sample code would be great!
Cheers,
Adam