SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL request
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ondra
Starting Member

1 Posts

Posted - 03/03/2014 :  06:04:51  Show Profile  Reply with Quote
Hi, could anyone please help with with following SQL reguest?

With
xy AS
(select a,b
from XXX
where time=201301),
xx AS
(select c,d,e,f,g
from YYY
where year=2013 and month=1)
select a,b,c,d,e,f,g
from xx
left join xy on xy.a=xx.b

The problem is that I have no idea, how to write one reguest that would generate results for the whole year. So basically I have to rewrite this request for each month (so time=201302 for month=2 etc.)

I am sure it is not difficult task, but I can not solve it.

Many thanks








Edited by - Ondra on 03/03/2014 06:28:19

kennejd
Starting Member

USA
11 Posts

Posted - 03/03/2014 :  08:55:46  Show Profile  Reply with Quote
Can you include some sample data? It's difficult to help without it...:) There are numerous ways to filter for a year at a time....where year = 2013....leave out the month. Of course I may be way off base....not knowing exactly what you're trying to achieve.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/03/2014 :  11:43:34  Show Profile  Reply with Quote
As i understand you want make filter for full year

ie

where year=2013

and the group by year,month to get result for each month

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000