Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Date Query

Posted on 2013-01-08
2
Medium Priority
?
213 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 43

Accepted Solution

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

783 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