Solved

SQL Date Query

Posted on 2013-01-08
2
198 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

752 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