Ask a question about mysql and groupby grouping query.

Source: Internet
Author: User
Ask a question about mysql and groupby grouping query. the data table field is of the datetime type, the saved value is 2009-02-10:20:11. I want to write an SQL statement for querying by number of days, that is, the number of records on the current day is two records, with the dates 2009-02-, respectively, 2009-02-the results show that the number of friends I know in is 2. I would like to thank you first-ask a mysql, group by date grouping query question.
The data table field is of the datetime type. the saved value is 12:20:11.
I want to write an SQL statement to query by number of days.
That is, how many records are there on the day?
There are two records with dates: 12:20:11, 22:20:11
Result Display
2009-02-10 quantity 2

Thank you!



------ Solution --------------------
SQL code
Select count (left (shijian, '10') as sl, left (shijian, '10') as sj from tablea group by sj

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.