Sql server to oracle
984796Jan 14 2013 — edited Jan 14 2013Hi,
I am new to oracle and am trying to convert a sql server query to oracle. What the query does is basically get a range of dates from 2011(high year) to 2001(low year) and then loops thru each year and gets the count and inserts into temp table. Can someone please help me with this. Thanks for your help in advance
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), TotalCount char(30), test1 char(30), test2 char(30),
test3 char(30), test4 char(30), test5 char(30), test6 char(30), test7 char(30))
INSERT INTO @TempTable (YearID, ToalCount, test1, test2, test3, test4, test5, test6, test7)
Select @Year, @TotalRecords, convert(decimal(4,1),round(convert(decimal(15,5),(select count(*) ....) * 100) / convert(decimal(15,5),(@TotalRecords)),2)),
convert(decimal(4,1),round(convert(decimal(15,5),(select count(*) ....) * 100) / convert(decimal(15,5),(@TotalRecords)),2)),
convert(decimal(4,1),round(convert(decimal(15,5),(select count(*) ....) * 100) /
convert(decimal(15,5),(@TotalRecords)),2)),
set @highyear = (@highyear - 1) end