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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass dynamic operator as parameter

Status
Not open for further replies.

rose4567

Programmer
Mar 12, 2007
70
US
I am converting a report from an old legacy system and I am not sure I can duplicate the functionality. I am writing the report in Reporting Services 2005 and looking for input or feedback.

The legacy reporting system allowed the user to choose their own operator when querying a dollar amount field: >, <, >=, <=, =, NOT.

Does anyone have any ideas on whether or not it's possible to create/pass parameter that supports a dynamic operator? Or, whether or not it's a parameter, is is possible to incorporate a dynamic operator where user has control?

Here's a sample of what I'm trying to accomplish:

When the user is prompted for trans amount they enter their specified operator and amount to generate a queries like:

trans_amt > 0
trans_amt < 15
trans_amt = 30

Ideas, tricks, tips anyone??
 
If SQL Server is the source of data, you can use logic like below in your query. I assume you can also utilize this type of logic in other DBMS's, of which I do not know the syntax.

Code:
SELECT * FROM YourTable 
WHERE
(@Operator = '=' AND trans_amt = @Value)
OR
(@Operator = '>' AND trans_amt> @Value)
OR
(@Operator = '<' AND trans_amt< @Value)
etc....
 
Worked like a charm! Beautiful! Thank you so much. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top