Sqlserver Query

in sqlserver

 

u have column1,column2,column3,column4 in a table called table1

table1 structure

1st row : 20,40,30,60

2nd row: 15,30,45,90

 

expected result :

firstval ,secondval,thirdval

2ndcol/1stcol , 4thcol/3rdcol,     (4thcol/3rdcol)/(2ndcol/1stcol)

 

for achieving this in a simplified way

select  AAA.FirstValue as firstval,AAA.SecondValue as secondval,(AAA.SecondValue/AAA.FirstValue) As thirdval from (select (column2/coumn1) as FirstValue , (column4/column3) as SecondValue from table1)  as AAA

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: