Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

SQL DATE filter on sales history

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
0
Jeremy Kirkbride
Asked:
Jeremy Kirkbride
  • 3
  • 3
1 Solution
 
SharathData EngineerCommented:
You need to extract only month/ year from the date field before applying the filter. What is your database?
0
 
Jeremy KirkbrideAuthor Commented:
SQL
0
 
SharathData EngineerCommented:
SQL is not a database. I have asked if you are working in SQL Server/Oracle/DB2/MySQL or any other database?
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Jeremy KirkbrideAuthor Commented:
SQL Server 2012, but I am writing a query with SQL Server Management Studio. That help?
0
 
SharathData EngineerCommented:
try this.
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 RIGHT(CONVERT(VARCHAR(10), HDR.inv_dt, 103), 7) = '11/2013' 
 GROUP BY HDR.slspsn_no 

Open in new window

0
 
Jeremy KirkbrideAuthor Commented:
Thanks so much, exactly what I needed. I'm sure simple for you, but I'm new to SQL
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now