Just
SELECT DISTINCT RegDate from Employees Order By RegDate
Tom
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have the following sql
SELECT DISTINCT RegDate from Employees
In the above sql, how can I ORDER BY RegDate. If not possible , how can get distinct dates with order by
Thanks
Pol
Just
SELECT DISTINCT RegDate from Employees Order By RegDate
Tom
Hi @Polachan Paily ,
According to the positive order of RegDate to get different dates:
SELECT DISTINCT RegDate from Employees Order By RegDate ASC
Sort in reverse order according to RegDate:
SELECT DISTINCT RegDate from Employees Order By RegDate DESC
The default sorting method of SQL Server is in accordance with the positive sequence of the fields. When ASC and DESC are omitted, they will be sorted in the positive order of the fields.
In other words, the following two pieces of code are equivalent:
SELECT DISTINCT RegDate from Employees Order By RegDate
SELECT DISTINCT RegDate from Employees Order By RegDate ASC
For more details, please refer to:
SELECT - ORDER BY Clause (Transact-SQL)
If you have any question, please feel free to let me know.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.