Hello All
I'm using VS2012 and I have tried to modify my SQL statement ORDER BY section to add an IF ELSE option. The error says the issue is close to the word ORDER. Below is the SQL. I used this as a resource (link below) , but I'm clearly missing something, anyone have a clue?
https://msdn.microsoft.com/en-GB/library/ms182717.aspx
thanks
Peter
SELECT Date_Table.Counter, Date_Table.Type, Date_Table.Date, Date_Table.FK, Date_Table.Allocated, Person_data_table.Team, Person_data_table.First_Name
FROM Date_Table INNER JOIN Person_data_table ON Date_Table.FK = Person_data_table.MK
WHERE (Date_Table.Date = @Date) AND (Person_data_table.Team = @team)
//Above this point worked OK, as did a single ORDER BY statement........
IF (@team = "Planning")
BEGIN ORDER BY Person_data_table.First_Name
END
ELSE
ORDER BY Date_Table.Allocated, Date_Table.Type