Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 CrystalReports
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 18:16pm
Edited 11-May-13 19:39pm
v6
Comments
Maciej Los at 11-May-13 4:39am
   
What kind of database (Access, SQL Server, PostgreSQL, MySQL)?
 
What have you done / tried till now?
Mohi Uddin Sumon at 11-May-13 4:40am
   
Thank you Mr.Maciej Los
I have used sql server 2008
Maciej Los at 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 at 12-May-13 3:02am
   
Hi, have anyone to help me?

1 solution

Rate this: bad
good
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)
where 
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....
  Permalink  
v2
Comments
Maciej Los at 11-May-13 8:04am
   
Good example!
+5
Adarsh chauhan at 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
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 12 May 2013
Copyright © CodeProject, 1999-2014
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