Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL DATE filter on sales history

Posted on 2013-12-27
6
Medium Priority
?
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 41

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 41

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 41

Accepted Solution

by:
Sharath earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

719 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