Sean Lange (5/5/2015)
minimay (5/5/2015)
nevermind i figured it out
Declare @Julycount int
Set @Julycount= (Select Count(*) From orders Where MONTH(OrderDate) = 7)
print 'The total orders for july is ' + Cast(@JulyCount as varchar)
That will get you the count of orders in July for ALL years. Once you have orders in more than 1 year I don't think this will do what you want.
You could add logic to the where clause for a specific year, if you wanted.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]