Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 need help in Select statement

Author  Topic 

kahwinlee
Starting Member

2 Posts

Posted - 2006-05-24 : 03:03:55
i wish to generate a sql which is not related to any table and can show the following result with two parameter 1997 and 2000:

--------
| year |
--------
| 1997 |
| 1998 |
| 1999 |
| 2000 |
--------



My Spring Without PocKet

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-24 : 03:08:03
Use the function listed over here..

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47685&SearchTerms=Numbers,table

Select * From F_TABLE_NUMBER_RANGE(1997,2001)

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-24 : 03:08:15
Why do you need this?


Declare @first int, @last int
Select @first=1997, @last=2000
Declare @years table(years int)

While @first<=@last
Begin
Insert into @years Select @first
Set @first=@first+1
End
Select years from @years


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-24 : 03:12:55
quote:
Originally posted by chiragkhabaria

Use the function listed over here..

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47685&SearchTerms=Numbers,table

Select * From F_TABLE_NUMBER_RANGE(1997,2001 2000)

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.




KH

Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-24 : 03:15:34


If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

kahwinlee
Starting Member

2 Posts

Posted - 2006-05-24 : 03:17:18
Due to the limitation of i-Net crystal clear report, I need to group the data by year and the searching criteria is two ?year, so I trying to generate a sub-report based on the year parameter...

really hard to say, but it seems like so stupid ... I'm really stuck at here 2 days already...

by the way, I'm using MySQL Server 5.0 and facing problem in both sql u guys are suggested, for this sql :Select * From F_TABLE_NUMBER_RANGE(1997,2001) <= it seems like only available for SQL Server...


My Spring Without PocKet
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-24 : 03:18:57
oh!!

This is SQL Server Forum..

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-24 : 03:23:54
"I'm using MySQL Server 5.0"
Try dbforums.com


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-24 : 04:10:11
or try at www.MYSQL.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -