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...

there is a table having two columns no and name
and the data is
1 A
2 B
3 C

write a query that will result a horizontal output
A,B,C

Answer Posted / senthil kumar murugan

;WITH ABC (no, name) AS
(
SELECT 1, CAST('' AS VARCHAR(8000))
UNION ALL
SELECT B.no + 1, B.name + A.name + ', '
FROM (
SELECT Row_Number() OVER (ORDER BY no) AS no, name FROM
emp1) A
INNER JOIN ABC B ON A.no = B.no
)
SELECT TOP 1 name FROM ABC ORDER BY no DESC

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List down some advantages of sql stored procedure?

1014


What is blocking and how would you troubleshoot it? : sql server database administration

1093


What will be the maximum number of index per table?

1055


What is difference between rownum and row_number?

1022


What are the restrictions that views have to follow? : SQL Server Architecture

1058


How to encrypt Strored Procedure in SQL SERVER?

1225


what is bit datatype and what's the information that can be stored inside a bit column? : Sql server database administration

1043


What is the maximum size per database for sql server express?

1102


To automatically record the time on which the data was modified in a table, which data type should you choose for the column?

1004


Can we use where clause in union?

1123


What are differences in between sql server 2012 and sql server 2016?

1094


Name three of the features managed by the surface area configuration tool? : sql server security

1029


Can we write a distributed query and get some data which is located on other server and oracle database?

1275


What is apply operator in sql?

1045


How to check what was the last restore transaction LSN in Log shipping or Mirroring? when we don't have a Monitor or witness server.

3919