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
Do you know what are different types of replication in sql server?
What does normalization do to data?
While you are inserting values into a table with the insert into .. Values option, does the order of the columns in the insert statement have to be the same as the order of the columns in the table?
What is a result set object returned by mssql_query()?
What is the difference between varchar and nvarchar datatypes?
what is a schema in sql server 2005? : Sql server database administration
What command do we use to rename a db, a table and a column?
Name three of the features managed by the surface area configuration tool? : sql server security
How many database files are there in sql server 2000?what are they?
What are the steps you should follow to start sql server in single-user mode?
How to add a new dsn with the odbc driver for sql server?
What is the size of transaction log file?
what is a correlated sub-query? : Sql server database administration
Difference between Sql server reporting services and Crystal reports?
What are the steps you must follow to hide sql server instances?