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

Answers were Sorted based on User's Feedback



9. Write a query to list a new column with the difference in temp of the cities Delhi and Mumbai, ..

Answer / 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

9. Write a query to list a new column with the difference in temp of the cities Delhi and Mumbai, ..

Answer / pradip jain

select t1.name + ' and ' t2.name , t2.temp -t1.temp from
temp t1
join temp t2 on t2.id=t1.id+1

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More SQL Server Interview Questions

Can we use trigger new in before insert?

0 Answers  


Explain what are the events recorded in a transaction log?

0 Answers  


Can a stored procedure call another stored procedure. If yes what level and can it be controlled?

2 Answers  


wat is mean by trigger?.......normally wat use......when trigger used in sql........... plz cleary say with example.......

2 Answers   TCS, Wipro,


what is the use of database index(apart from the last searching of records) and what is the use of composite key?

1 Answers  


Explain Geography datatype in SQL Server

0 Answers   Infosys,


How to delete existing rows in a table?

0 Answers  


How can you check the level of fragmentation on a table?

0 Answers  


How do you read transaction logs

1 Answers  


Which command is used for user defined error messages?

0 Answers  


List few advantages of stored procedure.

0 Answers  


how to find 6th highest salary

0 Answers   Chetak Logistics,


Categories