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
 CTE issue
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

musclebreast
Yak Posting Veteran

56 Posts

Posted - 08/15/2012 :  15:28:23  Show Profile  Reply with Quote
HI,

@visakkh16...I'll asnwer my other mail later or tomorrow:)

I've got just a little issue with a CTE..I want create some temporarly table which i can use...I need two..one with the last day of each month...and another with the last day of a quarter




;WITH testtable(test)


AS (
	select '31/01/'

	union all

	select '28/02/'

	union all

	select '31/03/'

	union all

	select '30/04/'

	union all

	select '31/05/'
	
	union all

	select '30/06/'

	union all

	select '31/07/'

	union all

	select '31/08/'

	union all

	select '30/09/'

	union all

	select '31/10/'

	union all

	select '30/11/'

	union all

	select '31/12/'

), months(date1)



AS (
	select '31/03/'

	union all

	select '30/06/'

	union all

	select '30/09/'

	union all

	select '31/12/'

), quarters(date1)



AS (
	select test from testtable
)


select * from months



now when I do the select on table month...I get all values from table quarter...

Does anybody know why?

Kind regards,

Lara

musclebreast
Yak Posting Veteran

56 Posts

Posted - 08/15/2012 :  17:14:54  Show Profile  Reply with Quote
Hi,

I got it..hopefully....I did it as follows:



;WITH months(date)


AS (
	select '31/01/'

	union all

	select '28/02/'

	union all

	select '31/03/'

	union all

	select '30/04/'

	union all

	select '31/05/'
	
	union all

	select '30/06/'

	union all

	select '31/07/'

	union all

	select '31/08/'

	union all

	select '30/09/'

	union all

	select '31/10/'

	union all

	select '30/11/'

	union all

	select '31/12/'

),



quarters(date)

AS (
	select '31/03/'

	union all

	select '30/06/'

	union all

	select '30/09/'

	union all

	select '31/12/'

)

select * from quarters


it works..would you say it's a correct way?

Kind regards,

Lara
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47040 Posts

Posted - 08/15/2012 :  22:57:23  Show Profile  Reply with Quote
where are the year parts?



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

musclebreast
Yak Posting Veteran

56 Posts

Posted - 08/16/2012 :  06:57:14  Show Profile  Reply with Quote
I added these, as I did it for month and days...have it tested alot..and it seems working without any error.

Kind regards,

Lara
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.08 seconds. Powered By: Snitz Forums 2000