We help IT Professionals succeed at work.

SQL DATE filter on sales history

188 Views
Last Modified: 2014-01-03
I am trying to write a simple SQL query that sums a salesman sales by month, but the date seems to be my trouble.

What I need to see is summed sales by salesman for a particular month/year 11-2013


SELECT HDR.slspsn_no,SUM(LIN.sls_amt)
FROM oehdrhst_sql HDR
INNER JOIN oelinhst_sql LIN ON
HDR.inv_no=LIN.inv_no
WHERE HDR.inv_dt=(11-2013)
GROUP BY HDR.slspsn_no

As the above is written I get (0 row(s) affected)

Any help would be much appreciated
Comment
Watch Question

Sharath SData Engineer
CERTIFIED EXPERT

Commented:
You need to extract only month/ year from the date field before applying the filter. What is your database?

Author

Commented:
SQL
Sharath SData Engineer
CERTIFIED EXPERT

Commented:
SQL is not a database. I have asked if you are working in SQL Server/Oracle/DB2/MySQL or any other database?

Author

Commented:
SQL Server 2012, but I am writing a query with SQL Server Management Studio. That help?
Data Engineer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks so much, exactly what I needed. I'm sure simple for you, but I'm new to SQL
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.