Click here to Skip to main content
13,049,814 members (76,872 online)
Rate this:
Please Sign up or sign in to vote.
I will be very regretful if give me a proper solution of my question. From the following query I get the result as :

"select sp.MaintenceCode, sp.MDate, sp.PDes,sp.SPCode, s.SpareParts, " +
"em.EmpName as MaintainedBy, md.MachinaryName, sp.SPMCode "+
"from tblDailyMaintenceDetails dm "+
"inner join tblEmployeeInformation em on em.EmpCode=dm.EmpCode "+
"inner join tblSparePartsMaintenance sp on sp.MaintenceCode=dm.MaintenceCode "+
"inner join tblSpareParts s on s.SPCode=sp.SPCode "+
"inner join tblMachinaryDetails md on md.MDCode=dm.MDCode "+
"where md.MDCode='MDP-000001' and sp.MDate'15-May-2013' ";

The result is :

DMC-002 5/15/2013    not good    SPC-000002  Cable   HASNA BEGUM Toshiba SPM-000002
DMC-002 5/15/2013    not good    SPC-000001  Motor   HASNA BEGUM Toshiba SPM-000004

But I have to show this in crystal report like as follows :
DMC-002 5/15/2013    not good    SPC-000002  Cable,  Motor   HASNA BEGUM Toshiba SPM-000002

How can I do this? Please help.
Posted 10-May-13 17:16pm
Updated 11-May-13 18:39pm
Maciej Los 11-May-13 4:39am
What kind of database (Access, SQL Server, PostgreSQL, MySQL)?

What have you done / tried till now?
Mohi Uddin Sumon 11-May-13 4:40am
Thank you Mr.Maciej Los
I have used sql server 2008
Maciej Los 11-May-13 6:33am
Please, append headers to your example data and provide more information about the structure of table(s). Use "Improve Question" widget.
Based on which criteria do you want to split rows to column?
Mohi Uddin Sumon 12-May-13 3:02am
Hi, have anyone to help me?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi Mohi Uddin,

what i think you want to do is like--

I have a table as table1

Date	       Bill_no	cust_name	Item_name
2/2/2013	234	 ABC	    wireless mouse
2/3/2013	234	 ABC	    wireless keyboard
2/4/2013	234	 ABC	    mouse pad

and i want to show result as
Date	        Bill_no	  Item_name	              cust_name				
2/4/2013	234	wireless mouse,wireless keyboard,mouse pad	 ABC

I can do it in following way:
select Date,Bill_no,
select Item_name +',' from table1 a (nolock)
for xml path ('')
) as Item_Name,Cust_name
from table1 b(nolock)
where bill_no=234 and custName='ABC'
    group by Date,Bill_no,Cust_name

hope it will help you....
Maciej Los 11-May-13 8:04am
Good example!
Adarsh chauhan 14-May-13 7:48am
thanks Maciej Los

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 12 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100