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   To Refer this Site to Your Friends   Click Here
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
 
Where do you think the users names and passwords will be stored in sql server?  3
in emptable i want to retrive the name of employee whose name in 'J'char.exp: arjun,jagadesh,niranjan,anju,aaaj etc.  7
Following are some of the question related to below mentioned query? select e1.salary from employee3 e1 where 2= ( select count(distinct(e2.salary)) from employee3 e2 where e2.salary>=e1.salary ) 1) What the query returns? 2) How it works? - Detail explanation (what the sub query does, why it is (where 2=)....etc...Please?  3
WRITE A FUNCTION TO DISPLAY THE OUTPUT OF AN EXISTING TABLE RANGE LIKE COMMAM SEPERATED VALUES LIKE RANGE1,RANGE2,... TVS2
I have a table in which phno is one of the columns.i do have some values in tht phno column.i need to update phno column values with 0(zero) as prefix.give me a correct solution plz... Value-Labs5
How do you simulate a deadlock for testing purposes  1
What is the difference between views and stored procedures? Can we have input parameters for views?  3
About DTS usage ? Cognizent2
What is the difference Between Sql-server 2000 & 2005 Value-Labs2
If there is failure during updation of certain rows, what will be the state?  1
What are the all different types of Joins in SQL Server 2000, Anybody can explain each join with definition..Thanks in advance.... Siemens6
How will u get 5 years back record?  4
Hello all, I have data like :- year amt 2004 10 2005 20 2006 30 Now i want output as:- 2004 2005 2006 10 30 60 but i have to use here group by on year.So, i need a single query within that i can find.  2
how to know description of a table in sqlserver 2000  7
What's the difference between a primary key and a unique key? Wipro8
How do you check the performance of a query and how do you optimize it?  1
Explain Active/Active and Active/Passive cluster configurations?  1
write the query for taking database restore in sql?  2
can you any body tell me while running BCP Out in instance in sql server 2000 is getting error. Error = [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.?  1
how do we find every fifth record in a table  11
 
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