Solved

SQL Date Query

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

Accepted Solution

by:
EugeneZ 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Viewers will learn how the fundamental information of how to create a table.
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now