G
Guest
Can you use an IIF statement in an ORDER BY statement in SQL?
Trying to change the order depending on the if statement?
Trying to change the order depending on the if statement?
Duane Hookom said:It would take less time to try it this than to post the question in a news
group.
Open Northwind and create a query with this SQL
SELECT Employees.*
FROM Employees
ORDER BY IIf([LastName] Like "D*",[LastName],"A");
--
Duane Hookom
MS Access MVP
Paul Dennis said:Can you use an IIF statement in an ORDER BY statement in SQL?
Trying to change the order depending on the if statement?
Paul Dennis said:Thanks for this, worked fine but didn't resolve my problem. I have a sort
order of [No of Rides] desc, [Last Name] Desc, however when the [No of
Rides]
= 0 I want the sort order to swap to [No of Rides] desc, [Last Name] Asc.
Can it be done?
Duane Hookom said:It would take less time to try it this than to post the question in a
news
group.
Open Northwind and create a query with this SQL
SELECT Employees.*
FROM Employees
ORDER BY IIf([LastName] Like "D*",[LastName],"A");
--
Duane Hookom
MS Access MVP
Paul Dennis said:Can you use an IIF statement in an ORDER BY statement in SQL?
Trying to change the order depending on the if statement?
Duane Hookom said:Please respond with some sample records and the desired output.
--
Duane Hookom
MS Access MVP
Paul Dennis said:Thanks for this, worked fine but didn't resolve my problem. I have a sort
order of [No of Rides] desc, [Last Name] Desc, however when the [No of
Rides]
= 0 I want the sort order to swap to [No of Rides] desc, [Last Name] Asc.
Can it be done?
Duane Hookom said:It would take less time to try it this than to post the question in a
news
group.
Open Northwind and create a query with this SQL
SELECT Employees.*
FROM Employees
ORDER BY IIf([LastName] Like "D*",[LastName],"A");
--
Duane Hookom
MS Access MVP
Can you use an IIF statement in an ORDER BY statement in SQL?
Trying to change the order depending on the if statement?