Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

9. Write a query to list a new column with the
difference in temp of the cities Delhi and Mumbai, Mumbai
and Jammu and soon. Consider the following table :
City_id City Temp.
1 delhi 40
2 Mumbai 35
3 Jammu 32
4 Pune 18

Answer Posted / milena

Hi here is my sql code, tested and works :

select t.CityName As 'CityName1',t.CityTemp
As 'CityTemp1' ,t1.CityName As 'CityName2',t1.CityTemp
As 'CityTemp2',(t1.CityTemp-t.CityTemp)*(-1) As Difftemp
From Test as t inner join Test As t1
on
t1.CityId=t.CityId+1

Result is :

Delhi 40 Mumbai 35 5
Mumbai 35 Jammu 32 3
Jammu 32 Pune 18 14

If you want to remove the CityTemp1, CityTemp2, you can do
so from select statement. :)

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are acid properties? : Sql server database administration

1004


Can you explain what are various ways to enhance the ssrs report?

1004


What is dknf in normalization form?

1059


Explain foreign key in sql server?

1033


Ways to improve the performance of a SQL Azure Database?

125


Will the writetext statement activate a trigger?

1099


what is the difference between Tabular and Matrix report?

173


Explain about SQL server 2005?

983


Difference between uniqe index and uniqe constraint?

985


Can a rule be bound to any column of any data type?

965


What is dml command?

976


why would you use sql agent? : Sql server database administration

1221


How many replicas are maintained for each SQL Azure database?

142


What is stored in the mssqlsystemresource database? : sql server database administration

1035


Where do you find the default Index fill factor and how to change it?

1066