What is the right syntax for this query in MS-SQL 2005?
select case app.NAMED_USER
WHEN app.NAMED_USER > 50 AND app.NAMED_USER <=0 THEN 4
WHEN app.NAMED_USER > 500 THEN 9
WHEN app.NAMED_USER > 500O THEN 12
FROM APPLICATION app
WHERE app.NAME LIKE '%application 5%'开发者_JS百科
i get a error message below, which I can not decipher.. I presume, it involves the variable type or the syntax to use with operands.
I hope someone can help.
Greetings,
hein
I'd do it like this:
select
case
WHEN app.NAMED_USER > 50 AND app.NAMED_USER <=0 THEN 4
WHEN app.NAMED_USER > 500 THEN 9
WHEN app.NAMED_USER > 5000 THEN 12
end
FROM APPLICATION app
WHERE app.NAME LIKE '%application 5%'
Among other things, app.NAMED_USER can never be less than equal 0 and also greater than 50.
精彩评论