Home > database >  The same executable SQL command, but the Mysql always hint statements incorrect, for advice
The same executable SQL command, but the Mysql always hint statements incorrect, for advice

Time:10-12

Select dt=the convert (varchar (13), [time], 120),
Qty=count (1)
The from [table name]
Group by the convert (varchar (13), [time], 120)
The order by the convert (varchar (13), [time], 120)


The same why SQL statements can normal execution, but the MYsql is not?
Consult everybody a great god

CodePudding user response:

Select dt=the convert (varchar (13), event_time, 120),
Qty=count (1)
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
Group by the convert (varchar (13), event_time, 120)
The order by the convert (varchar (13), event_time, 120)



Select [SQL] dt=the convert (varchar (13), event_time, 120),
Qty=count (1)
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
Group by the convert (varchar (13), event_time, 120)
The order by the convert (varchar (13), event_time, 120)

(Err), 1064 - You have an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar (13), event_time, 120),
Qty=count (1)
The from th_event_info
Where ev 'at line 1

Below is the return error but I don't know where there are problems

CodePudding user response:

The Convert function usage right:
1. The convert (value, type)
2. The available types are: Binary, char (), the data, time, datetime, decimal, signed and unsigned

So it should be: select the convert (event_time, char (13)) * * * * *

CodePudding user response:

reference generation o f the princess reply:
Convert function usage right:
1. The convert (value, type)
2. The available types are: Binary, char (), the data, time, datetime, decimal, signed and unsigned

So it should be: select the convert (event_time, char (13)) * * * * *



Select dt=the convert (event_time, varchar (13), 120),
Qty=count (1)
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
Group by the convert (event_time, varchar (13), 120)
The order by the convert (event_time, varchar (13), 120)
Select [SQL] dt=the convert (event_time, varchar (13), 120),
Qty=count (1)
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
Group by the convert (event_time, varchar (13), 120)
The order by the convert (event_time, varchar (13), 120)

(Err), 1064 - You have an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar (13), 120),
Qty=count (1)
The from th_event_info
Where event_time be 'at line 1

Is such a change or an error,,, where there is wrong, please

CodePudding user response:

MYSQL DATE_FORMAT function is used

CodePudding user response:

 select DATE_FORMAT (event_time, 'Y - m - % % % d % % H: I: % % S') as dt, 
Count (1) the as qty
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
Group by DATE_FORMAT (event_time, 'Y - m - % % % d % % H: I: % % S')
Order by DATE_FORMAT (event_time, 'Y - m - % % % d % % H: I: % % S')

CodePudding user response:

reference 5 floor ACMAIN_CHM reply:
 select DATE_FORMAT (event_time, 'Y - m - % % % d % % H: I: % % S') as dt, 
Count (1) the as qty
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
Group by DATE_FORMAT (event_time, 'Y - m - % % % d % % H: I: % % S')
The order by DATE_FORMAT (event_time, 'Y - m - % % % d % % H: I: % % S')


Thank you very much, can I ask under the following circumstances in
Select DATE_FORMAT (event_time, 'Y - m - % d % %) as dt,
Count (1) the as qty
The from th_event_info
Where event_time between '2019-09-23 00:00:34. 000' and 'the 2019-09-25 00:00:34. 000'
And the event_type=1 and event_level='level 1'
Group by DATE_FORMAT (event_time, 'Y - m - % d % %)
The order by DATE_FORMAT (event_time, 'Y - m - % d % %')

This has preliminarily realized my needs,

If I want to find out statistics, the number of primary and secondary at the same time can achieve a statement directly?

Now the result is such,

The 33 2019-09-23
The 2019-09-24 215

Can generate a list, and the number of statistical yes secondary
  • Related