.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

SQL Query

Posted By: Dhilip.R     Posted Date: November 26, 2010    Points:2   Category :Sql Server
Hi,Experts

I have a table look like this

Date-----------Subject----------Class
------------------------------------------------
01.01.2010-----English----------I
01.01.2010-----English----------II
01.01.2010-----English----------III

I Need to Display the values look like the following


Date-----------Subject--------Class
------------------------------------------------
01.01.2010-----English--------I,II,III


Can anybody know answer me.....?


Thanks & Regards

Dhilip.R

Responses
Author: Sajid P K             
Posted Date: November 29, 2010     Points: 5   
Author: Senthilnathan             
Posted Date: March 03, 2011     Points: 20   

Hi Dhilip,
Try this below query,

SELECT date,subject, STUFF(
( SELECT ', ' + class FROM table_name ws where (ws.date= ws1.date) and (ws.subject= ws1.subject) FOR XML PATH('') ), 1, 1, '' )
As class from Table_Name ws1 group by date,subject

Author: Maverick             
Posted Date: March 07, 2011     Points: 20   

Hello,

You can use pivot command to accomplish this.

Thanks,
Maverick

Thanks,
Maverick


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend