Home > database >  The database problems
The database problems

Time:04-22

How SQL statement for this month there have been many people, a person in a day is repeated again

CodePudding user response:

Count (0) group by date, person

CodePudding user response:

 
Use tempdb for
GO
IF OBJECT_ID (' t ') IS NOT NULL
DROP TABLE t
CREATE TABLE (t
[name] [nvarchar] (10) NULL,
[ndate] [datetime] NULL
) ON the (PRIMARY)
Insert into t values (' zhang ', '2021-4-21 08:10:10)
Insert into t values (' zhang ', '2021-4-21 08:30:10)
Insert into t values (' bill ', '2021-4-21 09:10:10)
Insert into t values (' Cathy ', '2021-4-21 09:10:10)

Select distinct name, CONVERT (nvarchar (10), ndate, 10)
The from t
Line - how many how many head, even if don't feel directly, and the outer sheath child
Select count (*) from
(select distinct name, CONVERT (nvarchar (10), ndate, 10) ndate from t) tt
  • Related