Sorry if I didn't explain myself properly. I put in a max year anywhere from 2011 to 2001 and it should automatically loop thru till the min value in my case 2000. Oracle is driving me crazy, as I am new to oracle.
Marked as answer by manjunath_praj on Jan 14, 2013 08:29 PM
manjunath_pr...
Member
355 Points
121 Posts
Sql Query to Oracle
Dec 06, 2012 04:23 PM|LINK
Hi,
I am new to oracle, was pretty much involved in developing in sql server. Can someone please help me in converting the below query to oracle.
Declare @lowyear int
Declare @highyear int
Declare @TotalRecords int
Set @highyear = @Year
Set @lowyear = 2001
while @highyear >= @lowyear begin
Set @Year = @highyear
Set @TotalRecords = (select count(*) from .....)
DECLARE @TempTable TABLE (YearID char(45), .....)
INSERT INTO @TempTable (YearID, ....)
Select @Year, @TotalRecords, .........
set @highyear = (@highyear - 1) end
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: Sql Query to Oracle
Dec 06, 2012 04:33 PM|LINK
I can give you part of the answer. The oracle equivalent to
select 1 record
is
select 1 record
from dual
manjunath_pr...
Member
355 Points
121 Posts
Re: Sql Query to Oracle
Dec 06, 2012 04:48 PM|LINK
Sorry if I didn't explain myself properly. I put in a max year anywhere from 2011 to 2001 and it should automatically loop thru till the min value in my case 2000. Oracle is driving me crazy, as I am new to oracle.