0

I am working on a database and we are trying to make a script file that will give us the total number of orders in july.

How exactly would I say july because I know syntax is wrong and I would be using sum instead of count right?

Please help, This is what I tried

 use Cis11101_Northwind
 Declare @Julycount int
 Set @Julycount= (Select sum(*) From orders Where OrderDate = 'july')
 print 'The total orders for july is ' + Cast(@JulyCount as varchar)

1 Answer 1

1

You can USE MONTH to get month from the Date. if you want to match with July then MONTH(date) = 7

(Select sum(*) From orders Where MONTH(OrderDate) = 7)

OR

You can use DateName

  (Select sum(*) From orders Where datename(month, OrderDate) = 'July')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.