Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding union select and parameter to multiple joins 1

Status
Not open for further replies.

lorca

Technical User
Dec 20, 2005
64
GB
hello

I'm using sql reporting services, and i'd like a parameter for a distinct list of values (distinct d.TYPEDESC) for the user to select on the report.
I'd also like to add an 'ALL TYPES' at the top (which I've seen done as union select '-1' ?)
using my code below how would i go about adding this funcionality in ?
the values within column TYPEDESC are strings, I've tried using Report Paranmeters but got nowhere......................

many thanks
rich

Code:
SELECT     a.DURATION, a.TIMESTARTED, a.ENQUIRYID, a.LOCATION, 
                      a.SEQUENCENO, b.ENQUIRY_TYPES_ID, c.AUTHORITYID, 
                      d.TYPEDESC, d.ID
FROM         a INNER JOIN
                      b ON a.ENQUIRYID = b.ENQUIRY INNER JOIN
                      c ON a.LOCATION = c.LOCATIONID AND 
                      b.OWNINGLOCATION = c.LOCATIONID INNER JOIN
                      d ON b.ENQUIRY_TYPES_ID = d.ID
WHERE     (d.TYPEDESC = @TYPEDESC)
 
You would add a new dataset to the report within the dataset manager
Code:
SELECT       distinct d.TYPEDESC as TypeDescription, d.TYPEDESC as SearchValue, 2 as ListOrder
FROM         a INNER JOIN
                      b ON a.ENQUIRYID = b.ENQUIRY INNER JOIN
                      c ON a.LOCATION = c.LOCATIONID AND 
                      b.OWNINGLOCATION = c.LOCATIONID INNER JOIN
                      d ON b.ENQUIRY_TYPES_ID = d.ID
WHERE     (d.TYPEDESC = @TYPEDESC)
union
Select 'All Types' as TypeDescription, '*' as SearchValue, 1 as ListOrder
You then create a report parameter and base it off a query - select he new dataset form the list presented and all should be good !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top