I have ONE table A and if the parameters @x is 0 i want to ordering A by date, else by Name.
This is an example:
declare @x int set @x = 0
if(@x=0)(
SELECT * FROM A
order by DATE
)
else
(
SELECT * FROM A
order by Name
)
When try to do it SQL Server return 2 egual error as
Incorrect syntax near the keyword ‘order’.
What could i do?
1 Answer