SELECT
The UserName
, GMTDate
, the Sum (FlowCount) as FlowCount
[Type]
The FROM [LOGSERVER] [dbo]. [CDNHTTP]
Where DATEDIFF (month, [GMTDate], GETDATE ())=2//change this data can be a month
Group by [UserName], [GMTDate], [Type]
The order by [GMTDate]
This is MS SQL function, realized to mySQL to do now?
Has examined the mySQL with DATEDIFF but return it without parameters, DATE_SUB seems to also not line, do not know how
CodePudding user response:
Is about such a MSSQL table
The CREATE TABLE [dbo] [CDNHTTP] (
[ID]/int IDENTITY (1, 1) NOT NULL,
[UserName] [varchar] (50) NULL,
[GMTDate] [datetime2] (7) NULL,
[FlowCount] [float] NULL,
[Type] [varchar] (255), NULL,
PRIMARY KEY CLUSTERED
(
[ID] ASC
) WITH (PAD_INDEX=OFF, STATISTICS_NORECOMPUTE=OFF, IGNORE_DUP_KEY=OFF, ALLOW_ROW_LOCKS=ON, ALLOW_PAGE_LOCKS=ON) ON (PRIMARY)
) ON the (PRIMARY)
GO
The SET ANSI_PADDING OFF
GO
Records have the time, site, traffic is used, use agreement,
Flow in each site usage statistics, showed that on the day of the deadline for the month
Such as: need statistics each site traffic situation every day last month, MS SQL below
SELECT
The UserName
, GMTDate
, the Sum (FlowCount) as FlowCount
[Type]
The FROM [LOGSERVER] [dbo]. [CDNHTTP]
Where DATEDIFF (month, [GMTDate], GETDATE ())=1
Group by [UserName], [GMTDate], [Type]
The order by [GMTDate]
This month is just change parameter where DATEDIFF (month, [GMTDate], GETDATE ())=[color=# FF0000] 0
[/color]
By analogy, so how should the mySQL query the,
Thank you for the first time to use mySQL
CodePudding user response:
MS SQL is the
MySQL that seems to be no
CodePudding user response:
MYSQL datediff such useDATEDIFF (CURDATE (), [GMTDate])=2
CodePudding user response:
The SELECT DATEDIFF (' 2008-12-30 ', '2008-12-29') AS DiffDateMysql returned with this days,
CodePudding user response:
The