We help IT Professionals succeed at work.
Get Started

Sql query syntax  month as field name

Last Modified: 2012-05-11
I have the following sql statement that works fine currently.  I would like the sum case field month to actually be the current month.  so when I run this now it should be as may when viwed.  

sum(case when datedif = '12' then quantity else 0 end) as month
(SELECT     INV1.ItemCode, INV1.WhsCode, OINV.CardCode, OINV.ShipToCode, INV1.SubCatNum, INV1.U_SIF_CustPartRev, INV1.Quantity, OINV.DocDate, datediff(Month,oinv.docdate,CONVERT(DATETIME, '2011-05-02 00:00:00', 102))as DATEDif
                      INV1 ON OINV.DocEntry = INV1.DocEntry
WHERE    (OINV.DocType = 'i') AND (INV1.ItemCode = 'SP009600079-31T') AND (INV1.WhsCode = '10') AND (OINV.CardCode = '9600') AND (OINV.ShipToCode = '32')
Watch Question
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE