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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is field in algebra?

717


What are the mathematical functions supported by sql server 2005?

649


What specific conditions database should meet, before you can bulk copy data into it using bcp?

638


How to download microsoft sql server 2005 express edition?

683


What objects does the fn_my_permissions function reports on? : sql server security

643






Why do we need normalization?

576


How to create function without parameter in sql server?

647


What are approximate numeric data types in ms sql server?

667


How to maintain a fill factor in existing indexes?

603


how to determine the service pack currently installed on sql server? : Sql server database administration

649


Explain the difference between cross join and full outer join?

586


What is filter index?

610


What is coalesce in sql server?

634


How to choose all records from the table?

725


Tell me what are the advantages of using stored procedures?

649