Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql query

Author  Topic 

babuuser9
Starting Member

3 Posts

Posted - 2011-03-23 : 11:18:15
a b c

23 12 12

234 453 54

32 323 23

23 34 45

333 45443 534

i want output like

(23 + 12)/54
23(a) and 12(b) are in 1st row, but 54(c) is in 2nd row
that iteration should repeat
i am new to sql and i know it should be simple
can you guys help me out

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-03-23 : 11:28:10
SQL doesn't really work that way... use excel.

Corey

snSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!"
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-03-23 : 11:31:33
To do this, you need some way of ordering the rows. Data in a table is an unordered collection even though it may look like it is when you do a select query.

The ordering scheme can be either another column which has a row number, for example, or it could be based on some type of logic. But you need a way to order the rows.

Once you can do that, then doing what you described is relatively easy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-24 : 07:29:45
Search for running total and get some idea

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-24 : 07:31:50
quote:
Originally posted by Seventhnight

SQL doesn't really work that way... use excel.

Corey

snSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!"


Corey, where have you been all these days?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-03-24 : 08:50:32
I haven't been doing much SQL work... mostly .Net

Got a new job recently, so I've been adjusting to 2005/8 :P

I see alot of the same people are still cranking away at it...

Corey

snSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!"
Go to Top of Page
   

- Advertisement -