Home > database >  [] SQL query problem how to query a week last month week live data
[] SQL query problem how to query a week last month week live data

Time:10-12

The table name: Test
Column: dt, device_id

How to query data from 20200401 to 20200430 the inside every seven days?

CodePudding user response:

In a SQL run

CodePudding user response:

Is there any great god 0.0

CodePudding user response:

The SELECT aleem walji eeks, COUNT (1) num FROM
(SELECT WEEK (DATE_ADD (dt, INTERVAL 6 DAY), 2) weekes, device_id FROM Test
WHERE dt & gt;='2020-04-01' AND dt & lt;='2020-04-30'), a GROUP BY aleem walji eeks.

CodePudding user response:

The
reference 3 floor qq_18379499 response:
SELECT aleem walji eeks, COUNT (1) num FROM
(SELECT WEEK (DATE_ADD (dt, INTERVAL 6 DAY), 2) weekes, device_id FROM Test
WHERE dt & gt;='2020-04-01' AND dt & lt;='2020-04-30'), a GROUP BY aleem walji eeks.


Yes, the error
Error while compiling the statement: FAILED: ParseException line any always recognize input near 'INTERVAL' '6' 'DAY in the select expression

CodePudding user response:

My side to perform good ah, how can go wrong, you put your execution screen screenshots come out and see the

CodePudding user response:

Feel like your SQL editor cannot identify the function: DATE_ADD (dt, INTERVAL 6 DAY)

CodePudding user response:

DATE_ADD is a function of Mysql, it should be with the editor it doesn't matter
  • Related