I have Two table First have UserName and second is address,
in address table more than value relegated to UserName
table, i want to fetch 2nd address if exist other wise 1st
address access

Answers were Sorted based on User's Feedback



I have Two table First have UserName and second is address, in address table more than value relega..

Answer / arun

use Coalesec(addrress1,address2)

Is This Answer Correct ?    6 Yes 1 No

I have Two table First have UserName and second is address, in address table more than value relega..

Answer / krishan

Please solve my problem?

Is This Answer Correct ?    4 Yes 1 No

I have Two table First have UserName and second is address, in address table more than value relega..

Answer / manoj pandey

select user_name, coalesce(address1, address2) as address
from username u
left join address a
on u.userid = a.userid


For more Interview Questions check my blog: http://sqlwithmanoj.wordpress.com/interview-questions/

Is This Answer Correct ?    3 Yes 0 No

I have Two table First have UserName and second is address, in address table more than value relega..

Answer / sayali

Select u.name,coalesce(a.address2, a.address1)as Address
from Username u left join address a
on u.userid = a.userid

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query

3 Answers   RND Soft, Wipro,


Does the unique constraint create an index?

0 Answers  


Why is DML provided?

1 Answers   Ernst Young, Thomson Reuters,


What action plan is preferred if sql server is not responding?

0 Answers  


What are indexes in sql?

1 Answers  






What is difference between aggregate and analytic function?

0 Answers  


What are the different types of backups avaialabe in sql server 2005?

0 Answers  


What are SQL Jobs, please mention the use of it and how to create them.

1 Answers   247Customer,


employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 6 6 7 here the values r repeated two times.how to select the repeated values only.i.e 3,5,6 should alone come.

3 Answers  


Issues related in upgrading SQL Server 2000 to 2005 / 2008

0 Answers  


How to swap the data of two columns in a table. both the columns containing varchar values.

9 Answers  


What are the 3 types of schema?

0 Answers  


Categories