470,862 Members | 1,821 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

Urgent

hi

I have got a table as follows

col1 col2
---- -------
1 1183.74
2 1188.05
3 1202.08
4 1211.92
5 1213.55
6 1213.45
7 1213.54
8 1204.92
9 1210.13
10 1209.57
11 1205.45
12 1194.65
13 1194.22
14 1203.21
15 1205.72
16 1203.38
17 1198.68
18 1188
19 1189.24
20 1182.81
21 1177.07
22 1190.25
23 1191.17

now i want a query which yields the following results
here col3 for record 1 is calculated as follows

(1188.08/(1183.74-1))*100=0.364100225
col1 col2 col3
---- ---- ----------------
1 1183.74 0.364100225
2 1188.05 1.180926729
3 1202.08 0.818581126
4 1211.92 0.134497327
5 1213.55 -0.008240287
6 1213.45 0.007416869
7 1213.54 -0.710318572
8 1204.92 0.432393852
9 1210.13 -0.04627602
10 1209.57 -0.340616913
11 1205.45 -0.89593098
12 1194.65 -0.035993806
13 1194.22 0.752792618
14 1203.21 0.208608639
15 1205.72 -0.19407491
16 1203.38 -0.390566571
17 1198.68 -0.890980078
18 1188 0.104377104
19 1189.24 -0.540681444
20 1182.81 -0.485285042
21 1177.07 1.119729498
22 1190.25 0.077294686
23 1191.17
Jul 23 '05 #1
1 1009
SELECT Col1, Col2, (((SELECT Col2 FROM tbl tbl2 WHERE
tbl2.col1=tbl.col1+1)/NullIf(Col2, 0))-1)*100
FROM tbl

I changed the parenthesis around as the example had them in the wrong
places. I have not tested this as you didnt include the create table/insert
statements for your data.

Mr Tea

"Kalyan" <ka*****@gmail.com> wrote in message
news:8d**************************@posting.google.c om...
hi

I have got a table as follows

col1 col2
---- -------
1 1183.74
2 1188.05
3 1202.08
4 1211.92
5 1213.55
6 1213.45
7 1213.54
8 1204.92
9 1210.13
10 1209.57
11 1205.45
12 1194.65
13 1194.22
14 1203.21
15 1205.72
16 1203.38
17 1198.68
18 1188
19 1189.24
20 1182.81
21 1177.07
22 1190.25
23 1191.17

now i want a query which yields the following results
here col3 for record 1 is calculated as follows

(1188.08/(1183.74-1))*100=0.364100225
col1 col2 col3
---- ---- ----------------
1 1183.74 0.364100225
2 1188.05 1.180926729
3 1202.08 0.818581126
4 1211.92 0.134497327
5 1213.55 -0.008240287
6 1213.45 0.007416869
7 1213.54 -0.710318572
8 1204.92 0.432393852
9 1210.13 -0.04627602
10 1209.57 -0.340616913
11 1205.45 -0.89593098
12 1194.65 -0.035993806
13 1194.22 0.752792618
14 1203.21 0.208608639
15 1205.72 -0.19407491
16 1203.38 -0.390566571
17 1198.68 -0.890980078
18 1188 0.104377104
19 1189.24 -0.540681444
20 1182.81 -0.485285042
21 1177.07 1.119729498
22 1190.25 0.077294686
23 1191.17

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Stefan Bauer | last post: by
28 posts views Thread by Tamir Khason | last post: by
16 posts views Thread by | last post: by
7 posts views Thread by zeyais | last post: by
33 posts views Thread by dembla | last post: by
8 posts views Thread by ginnisharma1 | last post: by
3 posts views Thread by N. Spiker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.