Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: cross tab fild data show as row with comma seprate Post Reply Post New Topic
Author Message
krsnapv
Newbie
Newbie


Joined: 09 Apr 2009
Location: India
Online Status: Offline
Posts: 3
Quote krsnapv Replybullet Topic: cross tab fild data show as row with comma seprate
     Posted: 01 May 2009 at 6:24am
Hi all,
 
I hav requirment as follow by using the cross tab, data shoul show like
                      
companyType   Employee            Dept1 Amnt           Dept2  Amnt     Totals
 
 Ctype1
               emp1, emp2, emp3       1000                    1000                 2000
 
Ctype2
               emp4, emp5..                  2000                    2000                 4000
 
Totals                                           3000                      3000                 6000  
 
for me its displaying like bellow but it should not be
 
companyType   Employee            Dept1 Amnt           Dept2  Amnt     Totals
 
 Ctype1
               emp1                            500                    500                 1000   
               emp2                            500                    500                 1000  
 
             Totals                          1000                    1000                 2000
 
Ctype2
               emp4                         1000                    1000                 2000
               emp5                         1000                    1000                 2000
 
            Totals                           2000                    2000                 4000
 
Totals                                     3000                      3000                 6000
 
Can you find a solution for this
Thanks, kris
 
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 08 May 2009 at 1:09am
Hi
 
Do the following........ create a function in SQL as below
CREATE FUNCTION [dbo].[ufn_empnames] ( @companytype varchar(50) )
RETURNS VARCHAR(8000)

AS

BEGIN

DECLARE @empnames VARCHAR(8000)

SELECT @empnames = ISNULL(@empnames + ', ', '') + [employee]

FROM cross_emp

WHERE companytype = @companytype

RETURN @empnames

END

 

Then code the sql as below

select

companytype,

[dbo].[ufn_empnames](companytype),--this is where you call the function created above

dept1amt+dept1amt as dept1,

dept2amt+dept2amt as dept2,

sum(dept1amt+dept2amt) as total

From cross_emp

group by companytype,dept1amt,dept2amt

 
 
 
output

companytype (No column name) dept1 dept2 dept1total
Ctype1           emp1, emp2        1000 1000 2000
Ctype2           emp4, emp5         2000 2000 4000

for vertical totals you can insert summary from crystal once the report is created.
 
cheers
Rahul


Edited by rahulwalawalkar - 08 May 2009 at 1:10am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum