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
What are recommended options to be used while using db mirroring? : sql server database administration
What is it’s similarity with sql server?
What to perform pattern match with the like operator?
Explain what is cte (common table expression)?
How to remove duplicate rows from table except one?
what are the reporting service components in SSRS?
What is unpivot?
How to check parameter value in stored procedure sql server?
What is Fragmentation and Defragmentation? For 32GB Table,How can we do the fragmentation?
How to use “drop” keyword in sql server and give an example?
1. Tell me your daily activities 2. If sql server installation fails at time installation what will do 3. Where does the sql server installation log details are stored 4. After the installation what will you do for memory configuration 5. What is the difference between SQL max maximum memory and AWE memory 6. How will you configure AWE memory 7. How will setup an email alert for the backup job 8. After the SQL installation what are the jobs will you configure 9. What does –g mean in the sql startup parameter 10. What is the difference between Bulked log and Full recovery model 11. What is the difference between mirroring and log shipping 12. What are the steps to be followed before in-place up gradation 13. After installing the patch the sql server does not start and application team tells to rollback the changes .In this scenario what will you do
What are distinctive joins find as a part of sql?
Mention the different types of triggers?
In my application I have a process which picks the scanned files (tif format) from a shared location and it links to application and shown on it.The actuall issue is that my process picks the file before it is completly written or scanned which results in displaying few parts of the image or incomplete image.I need to check if the file is not completly scanned or written then do not link it to application.Please help if any body tell me that how can i check that file is in written phase or locked through DTS.thanking you in advance
How is sql used in sql server?