Solved

SQL DATE filter on sales history

Posted on 2013-12-27
6
170 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
0
Comment
Question by:Jeremy Kirkbride
  • 3
  • 3
6 Comments
 
LVL 40

Expert Comment

by:Sharath
ID: 39742126
You need to extract only month/ year from the date field before applying the filter. What is your database?
0
 

Author Comment

by:Jeremy Kirkbride
ID: 39742278
SQL
0
 
LVL 40

Expert Comment

by:Sharath
ID: 39742324
SQL is not a database. I have asked if you are working in SQL Server/Oracle/DB2/MySQL or any other database?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:Jeremy Kirkbride
ID: 39742465
SQL Server 2012, but I am writing a query with SQL Server Management Studio. That help?
0
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
ID: 39752240
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
 

Author Closing Comment

by:Jeremy Kirkbride
ID: 39753607
Thanks so much, exactly what I needed. I'm sure simple for you, but I'm new to SQL
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
either24  challenge 19 97
ShiftLeft challenge 21 82
linearIn  challenge 23 110
Problem to refer to value 8 50
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question