Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

on line cluster can we make if yes tell me the procedure

2005


What is a trace frag? Where do we use it?

1083


Explain sub-query?

930


Explain sql server service broker?

954


How do you debug a procedure in sql server?

923


Write a sql query to delete duplicate records from a table called table1

1008


Explain temporary table vs table variable by using cursor alternative?

975


What do you understand by user-defined function in the sql server and explain the steps to create and execute a user-defined function in the sql server?

935


What does truncate do?

920


How many types of keys are there?

1012


Suppose you want to implement the following relationships while designing tables. How would you do it?a.) One-to-oneb.) One-to-manyc.) Many-to-many

925


What is sql server used for?

1020


What is instead of dml trigger?

977


What happens if null values are involved in datetime operations?

952


Why transaction is important?

960