The Ashes

Technology, Science and other news
April 10, 2009

Daily Report Using DATEPART in SQL

Posted by : admin
Filed under : General

I was working on a query today that I have never tackled before and thought I would share.  We wanted to see what our highest one day total for applications received were on our carrers page.

First step was to group by each of the date.  I am sure there is a DateTime function in SQL that I don't know that would have made this eaiser, but I got arround my limitation with DATEPART.  I extracted the year, the month and the day and grouped by each of them.

GROUP BY DATEPART(yy, CreateDate), DATEPART(mm, CreateDate), DATEPART(DD, CreateDate)

Then it is as simple as counting one of the elements that has been grouped.  My final query:

SELECT COUNT(DATEPART(yy, CreateDate)) AS Total, 
DATEPART(yy, CreateDate) AS Year, 
DATEPART(mm, CreateDate) AS Month,
DATEPART(DD, CreateDate) AS Day
FROM JobApplications
GROUP BY DATEPART(yy, CreateDate), DATEPART(mm, CreateDate), DATEPART(DD, CreateDate)
ORDER BY Year DESC, Month DESC, Day DESC

There it is, a total number of applications recieved per day.

Tags :

No Comments

(required)
(will not be published) (required)
(opitional)

cciash.com EN ES IT DE PT CZ FR RU
October 2018
M T W T F S S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031  

Pages

Categories

Resources

There are many online poker site where you can play but at poker.hk you can play the poker games with all the knowledge you need related to the game with the poker school available in both the English and Chinese language.

Super Casino

Now you can bet on any sports and any sporting events from all the comfort from your home. Bet770 allows you to bet on any events and match with in just 3 clicks. They also offers great odds on football betting for every premier and champions league match. Get £50 free in bets when you register.

Bingo770, offering best online bingo games with £7.70 free no deposit Bonus!