How do you have 2 order by in SQL Server
Can you have a single SQL that order events by current day then future dates and within current day 开发者_运维知识库and future dates in alphabetic order?
Please show me an example?
Thanks :)
You can use something like
SELECT *
FROM TABLE
ORDER BY Col1 ASC, Col2 DESC,...
Have a look at ORDER BY Clause (Transact-SQL)
[ ORDER BY
{
order_by_expression
[ COLLATE collation_name ]
[ ASC | DESC ]
} [ ,...n ]
]
ORDER BY CASE WHEN date = CurrentDate THEN 0 ELSE 1 END, AlphaField
You probably need something like:
where publishedAt>CURRENT_TIMESTAMP order by publishedAt asc, title asc
精彩评论