Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Declare @i int, @data1 date,@data2 date,@cost1 real, @cost2 real,@result real,@a real
- Declare @tableNaso Table (table_data date,result real)
- Declare @tableUSD Table (table_data1 date,result1 real)
- Declare @result_table Table (table_data1 date,res varchar(50))
- Declare Naso_Cursor Cursor global forward_only dynamic read_only
- For Select Date, ClosingPrice from MailRuCostNaso
- Open Naso_Cursor
- set @i=0
- Fetch next from Naso_Cursor into @data1,@cost1
- while @@FETCH_STATUS=0
- begin
- set @i = @i+1
- FETCH NEXT FROM Naso_Cursor into @data2,@cost2
- if (@cost2 =0 )
- begin
- set @cost2= (Select ClosingPrice from MailRuCostBer where Date=@data2)
- end
- set @result=@cost2-@cost1
- Insert into @tableNaso (table_data,result) values (@data1,@result)
- set @data1=@data2
- set @cost1=@cost2
- end
- close Naso_Cursor
- deallocate Naso_Cursor
- Declare USD_Cursor Cursor global forward_only dynamic read_only
- For Select Date, ClosingPrice from USDCos
- Open USD_Cursor
- set @i=0
- Fetch next from USD_Cursor into @data1,@cost1
- while @@FETCH_STATUS=0
- begin
- set @i = @i+1
- FETCH NEXT FROM USD_Cursor into @data2,@cost2
- set @result=@cost2-@cost1
- Insert into @tableUSD (table_data1,result1) values (@data1,@result)
- set @data1=@data2
- set @cost1=@cost2
- end
- close USD_Cursor
- deallocate USD_Cursor
- Declare Result_Cursor Cursor global forward_only dynamic read_only
- For Select table_data,result from @tableNaso
- Open Result_Cursor
- set @i=0
- Fetch next from Result_Cursor into @data1,@cost1
- while @@FETCH_STATUS=0
- begin
- set @i = @i+1
- set @a=( Select result1 from @tableUSD where table_data1=@data1)
- if (@a>0 and @cost1>0)
- Insert into @result_table(table_data1,res) values (@data1,'both grows')
- if (@a>0 and @cost1<0)
- Insert into @result_table(table_data1,res) values (@data1,'Rub grows MailRu falls')
- if (@a<0 and @cost1>0)
- Insert into @result_table(table_data1,res) values (@data1,'MailRu grows Rub falls')
- if (@a<0 and @cost1<0)
- Insert into @result_table(table_data1,res) values (@data1,'both falls')
- if (@a<0 and @cost1=0)
- Insert into @result_table(table_data1,res) values (@data1,'MailRu holds Rub falls')
- if (@a=0 and @cost1<0)
- Insert into @result_table(table_data1,res) values (@data1,'Rub holds MailRu falls')
- if (@a=0 and @cost1=0)
- Insert into @result_table(table_data1,res) values (@data1,'both holds')
- if (@a>0 and @cost1=0)
- Insert into @result_table(table_data1,res) values (@data1,'MailRu holds Rub grows')
- if (@a=0 and @cost1>0)
- Insert into @result_table(table_data1,res) values (@data1,'MailRu grows Rub holds')
- FETCH NEXT FROM Result_Cursor into @data1,@cost1
- end
- close Result_Cursor
- deallocate Result_Cursor
- select * from @result_table
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement