Peter Gustafsson
Peter Gustafsson

Reputation: 1

SQL for update query.

I want my sql query to stop using the query when a company have more then 4500 employees. But atm I dont get the right value when its under 4500, (price is 45$/employee)

{CASE WHEN ([company].[nremployees]* 45) <4500 
THEN 4500 
ELSE 
CASE WHEN ([company].[nremployees]* 45) > 4500 THEN
[company].[pricespecial] else
0 END END else [company].[servicebill] end}

Upvotes: 0

Views: 52

Answers (1)

Stefano Zanini
Stefano Zanini

Reputation: 5916

There are too many END, and you are overcomplicating it. Try with a simplified version

CASE
    WHEN [company].[nremployees] < 100 THEN 4500 
    WHEN [company].[nremployees] > 100 THEN [company].[pricespecial]
    ELSE [company].[servicebill] /* or 0, can't understand from your query */
END

Upvotes: 2

Related Questions