March 4, 2010 at 12:12 pm
I cannot get the following sort to execute in my report. Can you give me a clue how to get optional selecting and sorting?
WHERE
Case @Option
When 'S' then '(skills.sas_operator IN (@RangeStart))'
Else '(skills.sas_operator Between @RangeStart and @RangeEnd)'
END
ORDER BY
Case @SortOption
When 'S' then 'skills.sas_operator, skills.sas_station'
Else 'skills.sas_station,skills.sas_operator '
END
March 4, 2010 at 1:13 pm
Not sure this belongs in a BI forum,
but I believe that since you've enclosed the variables between quotes, they become part of the string and they are not interpreted as variables.
I'm not a T-SQL expert, but I think you have to do something like this (someone please correct me if I'm wrong):
'(skills.sas_operator IN (' + @RangeStart + '))'
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 4, 2010 at 4:38 pm
rhfishman
Can you give me a clue how to get optional selecting and sorting?
Use and IF ELSE statement (From Books On Line)
IF Boolean_expression
{ sql_statement | statement_block }
[ ELSE
{ sql_statement | statement_block } ]
Also note the first link in my signature block. Follow the directions contained in it, and you will most likely get a tested answer to your question. As it is without the table definition, sample data and required results we are left guessing at what you really require.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply