Home > database >  A SQL statement
A SQL statement

Time:09-29

Table A
LB JE DATA
1, 1.00 the 2018-02-01 12:11:10
1, 2.00 the 2018-02-01 13:02:03
2, 1.00 the 2018-02-01 16:01:01
2, 3.00 the 2018-02-01 18:09:25
1, 1.00 the 2018-02-02 14:01:07
1, 1.00 the 2018-02-02 19:03:02
2, 1.00 the 2018-02-02 18:09:07
1, 1.00 the 2018-02-03 08:02:58

In order to get the returned list
LB JE DATA
1, 3.00 the 2018-02-01
2, 4.00 the 2018-02-01
1, 2.00 the 2018-02-02
2, 1.00 the 2018-02-02
1, 1.00 the 2018-02-03

Statistical group is according to the number of days by date_format (DATA, 'Y - m - % d % %) and press group by LB SUM (JE)
A combined statement of how to write?

CodePudding user response:

You not write out
Select LB, SUM (JE), date_format (DATA, 'Y - m - % d % %) as ` DATE ` from TB group by LB, date_format (DATA,' Y - m - % d % % ')

CodePudding user response:

Select the date (DATA), LB, sum (JE)
The from TB
Group by the date (DATA), LB

CodePudding user response:

The SELECT lb, DATE (data) data, the SUM (je)
The from TB
Group by the Date (Data), lb
  • Related