SQLTeam.com | Weblogs | Forums

Strange Problem?


#1

Hi guys,

Normally i want to Divide a.price/b.price with this code. Because I want to see the next change in 3 minutes.

Select a.tarih,a.coin,(A.price),b.tarih,b.coin,(B.price) from (SELECT tarih, coin, MIN(price ) AS price
FROM dbo.cointahmin
GROUP BY tarih, coin order by tarih desc,coin OFFSET 300 ROWS
FETCH NEXT 100 ROWS ONLY) A,
(SELECT Top 100 tarih, coin, MIN(price ) AS price
FROM dbo.cointahmin
GROUP BY tarih, coin order by tarih desc,coin) B

My question;
Create a new column. In this column I would like to show the ratio of A.Price / B.Price when 3 minutes before(a.price) and current data(B.price) with same coin.

ADA/BTC A.price/B.price
ADX/BTC A.price/B.price
...
...
...
ZRT/BTC A.price/B.price

Thanks.Is it understandable?


#2

Hi It is possible using LEAD LAG functions in SQL Server 2012
My understanding is that the data will look like this
ID Number Age
1 45 300
2 30 500
You want to use 45 and 500 in the same select
Please correct me if i am wrong

select 45+500 for example