Solved

SQL Date Query

Posted on 2013-01-08
2
202 Views
Last Modified: 2013-01-08
Hi All i have the following query which all works fine

SELECT     TOP (100) PERCENT CAST(DATENAME(Month, Month) AS varchar) + ' ' + CAST(YEAR(Month) AS varchar) AS Month, COUNT(Sales_Order) AS Total_Ord, 
                      COUNT(Passed_Delivery) AS Passed, 100 * (COUNT(Passed_Delivery) / CAST(COUNT(Sales_Order) AS float)) AS Percentage, Month_No, Year_No
FROM         dbo.SC21_Customers
GROUP BY CAST(DATENAME(Month, Month) AS varchar) + ' ' + CAST(YEAR(Month) AS varchar), Month_No, Year_No

Open in new window


however aswell as keeping all of the previous dates and years etc, i now need it to include 2013 data, can anybody help to ammend it.

John
0
Comment
Question by:pepps11976
[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
2 Comments
 
LVL 2

Expert Comment

by:thombeck
ID: 38754143
Hi,

what do you mean with include 2013 data?
Can you please provide a sample, what you are expecting?
0
 
LVL 43

Accepted Solution

by:
Eugene Z earned 500 total points
ID: 38754153
there is no limit in your query

if you have 2013 data in your table - you should be ok -- if it is still problem select RAW data

select * FROM         dbo.SC21_Customers
where Year_No =2013 and post scrubbed (without real info!) data here
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

630 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