Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:30:35+00:00 2026-06-04T02:30:35+00:00

Possible Duplicate: SQL Count records within a month using a unix timestamp I have

  • 0

Possible Duplicate:
SQL Count records within a month using a unix timestamp

I have a table like this

+--------+------------+         
|    id  | datetime   |  
+--------+------------+   
|      1 | 1313405609 |  
|      1 | 1313144410 |  
|      2 | 1313405550 |  
|      1 | 1313405549 |  
+--------+------------+

datetime is php unix time, I want to group row by date(e.g. 20120517) and count every group items. Because the date of 1313405609,1313405550 and 1313405549 is 20110815, the result I want is:

+--------+------------+------------+  
|     id | datetime   |    Count   |  
+--------+------------+------------+  
|      1 | 1313405609 |      2     |  
|      1 | 1313144410 |      1     |   
|      2 | 1313405550 |      1     |  
+--------+------------+------------+

how can I do it with sql?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:30:36+00:00Added an answer on June 4, 2026 at 2:30 am

    Use FROM_UNIXTIME to convert a unix timestamp to a datetime. Then use DATE to get only the date part:

    select
      id,
      min(datetime) as datetime,
      count(*) as Count
    from
      YourTable t
    group by
      id,
      date(from_unixtime(datetime))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Incrementing a field in SQL using PHP I have a table (T1)
Possible Duplicate: How Do You Delete Duplicate Records In SQL I have a table
Possible Duplicate: SQL Select within 24 hours? I am using regular SQL to attempt
Possible Duplicate: SQL Server: Only last entry in GROUP BY I have a table
Possible Duplicate: SQL query to find Missing sequence numbers I have a table which
Possible Duplicate: dynamic sql pivot in sql server I have a table called Col_values
Possible Duplicate: Subtraction in sql statement I have a table with Presidents names and
Possible Duplicate: SQL - find records from one table which don't exist in another
Possible Duplicate: SQL Server dynamic PIVOT query? I have temporary table with following structure:
Possible Duplicate: SQL Server Database query help Hi, I have a problem that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.