SMKReddy
SMKReddy

Reputation: 107

SQL Query to find no of records created per day

I have one table with below details.

Id      Name       created_date
-----------------------------------------------
1       ABC   20-AUG-15 07.59.50.765000000 AM
2       ABD   20-AUG-15 08.59.50.765000000 AM
3       ABE   20-AUG-15 09.59.50.765000000 AM
4       ABF   20-AUG-15 06.59.50.765000000 AM
5       BCD   21-AUG-15 07.59.50.765000000 AM
6       BCE   21-AUG-15 08.59.50.765000000 AM.

I need the result of no.of Accounts created in one day (SQL Query). It should be generic.

Output:

 CountPerDay    created_date
------------------------------------------------
   4         20-AUG-15 07.59.50.765000000 AM
   2         20-AUG-15 08.59.50.765000000 AM

Upvotes: 1

Views: 7741

Answers (1)

user330315
user330315

Reputation:

This is a simple group by query:

select trunc(created_date), count(*) as num_created
from the_table
group by trunc(created_date);

The trunc() is necessary because in Oracle a DATE column contains a time part as well (or if your created_date is in fact a timestamp not a date).

Upvotes: 10

Related Questions