troubleshooting Question

Sql query syntax month as field name

Avatar of notasgoodasyou
notasgoodasyouFlag for Afghanistan asked on
Microsoft SQL Server 2008Microsoft SQL Server 2005
11 Comments1 Solution749 ViewsLast Modified:
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')

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros