SQL Server Server query - Count distinct DateTime field

后端 未结 5 1653
甜味超标
甜味超标 2020-12-30 08:43

Supposing we have the following records in an SQL Server table.

Date
19/5/2009 12:00:00 pm
19/5/2009 12:15:22 pm
20/5/2009 11:38:00 am

What

5条回答
  •  心在旅途
    2020-12-30 09:17

    After Googling found this one too...

    SELECT CAST(FLOOR(CAST(Expr1 AS FLOAT)) AS DATEtime) AS Expr1,

    COUNT(*) AS Expr2

    FROM MY_TABLE

    GROUP BY

    CAST(FLOOR(CAST(Expr1 AS FLOAT)) AS DATEtime)

    The cons?

    1. High speed execution
    2. The results returned are in the original locale. Ex for Greek 19/5/2009

    Thank you all

提交回复
热议问题