Solved

Count number of entries per day

Posted on 2011-02-23
509 Views
Hi

I need to count the numbers of entries per day in a database.

Then I need the result to be displayed so that I can see how many entries there were per day.

0
Question by:jensjakobsen

LVL 32

Expert Comment

ID: 34963879

select convert(datetime, datefield, 101) as Daily, Count(*)
from table
group by Daily
0

LVL 1

Author Comment

ID: 34963928
Thanks for a very quick response.

However that example showed me the number of 1 (one) per entry.

Example:

If the date 02/02/2011 had 12 entries I get 12 entries and not 02/02/2011 = 12

Let me know if I'm unclear.
0

LVL 18

Accepted Solution

sventhan earned 500 total points
ID: 34963945
select convert(varchar, datefield, 110) as Daily, Count(*)
from table
group by convert(varchar, datefield, 110)
0

LVL 1

Author Comment

ID: 34963988
Superb!!

I love you.
0

LVL 32

Expert Comment

ID: 34964073
Missed the group by
0

LVL 40

Expert Comment

ID: 34964362
You can simply convert to DATE if you are on SQL Server 2008.
``````select convert(date, datefield) as Daily, Count(*) Cnt
from table1
group by convert(date, datefield)
``````
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.