ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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
 Question Submitted By :: Akjain
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
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
Pradip Jain
 
  Re: 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
# 2
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 ?    1 Yes 0 No
Milena
 
 
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What is a Stored Procedure?  7
What is row by row processing ?  1
Explain different isolation levels?  3
Please give me the SP for the below scenario. I have two tables named Table1 and Table2...I need to fetch record by record from Table1 and insert the record in to table2 where the value in the sno column of the table1 is even number. Value-Labs4
PC(code, model, speed, ram, hd, cd, price) Find the hard drive sizes that are equal among two or more PCs. APX2
What is the diff between Dynamic queries and static queries ICS-Integrated-Computer-Solutions1
How to list all tables having unique constraints in any of the columns in a database.  1
WRITE A FUNCTION TO DISPLAY THE OUTPUT OF AN EXISTING TABLE RANGE LIKE COMMAM SEPERATED VALUES LIKE RANGE1,RANGE2,... TVS2
what is the difference between sql query and google query? TCS6
Explain DBMS, RDBMS?  4
How can I create a plain-text flat file from SQL Server as input to another application?  2
What are three SQL keywords used to change or set someone?s permissions?  3
how to give input dynamically to a insert statement in sqlserver HCL2
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? HCL1
What is the use of MOVE keyword in restore command IBM2
what is difference between having and where clause ?  2
write the query for taking database restore in sql?  2
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  2
What is the difference between a Local temporary table and a Global temporary table? How is each one used?  1
how to select 5 to 7 rows from a table, which contains 10 rows? IBM14
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com