Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: need help Post Reply Post New Topic
Author Message
tsar
Newbie
Newbie
Avatar

Joined: 25 Apr 2007
Online Status: Offline
Posts: 6
Quote tsar Replybullet Topic: need help
     Posted: 11 Mar 2008 at 1:46pm

Hi Crystal-report-experts,

I hope i can find some help here;

I have 1 table 'list' with 3 fields: 'Class', 'value' and 'num'

'select * from list order by num,class' gives me :

class   - value - num
---------------------
FirstName - John - 1
Name -  Lennon - 1
FirstName - Ringo- 2
Name  - Star  - 2
Firstname  - Paul - 3
Name - mcartney  -3
Firstname - George - 4
Name  - Harrison  - 4 
....
... 


now i want a report that display these values like

John Lennon
Ringo Star
Paul Mcatrney
George Harrison
...
...

could someone point me in the right direction ?

IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 11 Mar 2008 at 10:03pm
Is this your table ?
Class                 Value                  Num
First Name         John                    1
First Name         Ringo                   2
First Name         Paul                     3
First Name        George                 4
Name                Lennon                1
Name                Star                     2
Name                Mcartney             3
Name                Harrison              4

For Oracle Database, use the SQL statement  below. For other database make appropriate changes to SQL statement.

Select a.value || ' ' || b.value, a.num from 
(select VALUE, num from list where class = 'First Name') a
inner join
(select VALUE, num from list where class = 'Name') b
on a.num = b.num;


Hope this will help.
                
IP IP Logged
tsar
Newbie
Newbie
Avatar

Joined: 25 Apr 2007
Online Status: Offline
Posts: 6
Quote tsar Replybullet Posted: 13 Mar 2008 at 1:11am
Txs for the reply...

i get a error on the query.
SQL not properly ended error

btw... my table are more like this

Class                 Value                  Num
First Name         John                    1
First Name         Ringo                   2
First Name         Paul                     3
First Name        George                 4
Name                Lennon                1
Name                Star                     2
Name                Mcartney             3
Name                Harrison              4
Birthday            09/10/1940         1
Birthday            07/07/1940         2
Birthday           18/06/1942          3
Birthday           25/02/1943          4
comment          comment John      1
comment          comment Ringo     2
comment          comment paul       3
comment          comment George  4


and i need a result like

John Lennon 09/10/1940 comment John
Ringo Star    07/07/1940 comment Ringo
Paul Mcartney 18/06/1942 comment Paul
George Harrison  25/02/1943  comment George

so if you could change the query...

  


Edited by tsar - 13 Mar 2008 at 5:26am
IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 13 Mar 2008 at 7:45am
Select a.value || ' ' || b.value, a.bday, a.comment, a.num from 
(select VALUE, birthday 'bday', comment, num from list where class = 'First Name' order by 4,1) a
inner join
(select VALUE, birthday 'bday', comment, num from list where class = 'Name' order by 4,1) b
on a.num = b.num;

 
Let me know if you get it right this time.
you might have to make changes to the SQL for your database. What is your database? This SQL is for Oracle.
I checked the SQl in my previous post. But I did not get a chance to check this.
IP IP Logged
tsar
Newbie
Newbie
Avatar

Joined: 25 Apr 2007
Online Status: Offline
Posts: 6
Quote tsar Replybullet Posted: 13 Mar 2008 at 9:08am
don't think this is ok..

select VALUE, birthday 'bday', comment, num from list....
"birthday" and "comment" is not a field... they are a value in the field 'Class'


database = oracle

IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 13 Mar 2008 at 10:22am

You are right. The query has to be corrected.

Select a.value || ' ' || b.value ||' ' || c.bday || ' ' || d.comment  from 
(select VALUE, num from list where class = 'First Name' order by 2) a
inner join
(select VALUE, num from list where class = 'Name' order by 2) b
on a.num = b.num
inner join
(select VALUE, num from list where class = 'Birthday' order by 2) c
on a.num = c.num
inner join
(select VALUE, num from list where class = 'comment' order by 2) d
on a.num = d.num;
give the first column which is the result of concatenation an alias
Hope this works. I have not tested the query.
IP IP Logged
tsar
Newbie
Newbie
Avatar

Joined: 25 Apr 2007
Online Status: Offline
Posts: 6
Quote tsar Replybullet Posted: 18 Mar 2008 at 2:20am
txs.
i will check this out
 
 
 
IP IP Logged
jhodz2001
Newbie
Newbie
Avatar

Joined: 20 Jul 2008
Location: Philippines
Online Status: Offline
Posts: 9
Quote jhodz2001 Replybullet Posted: 21 Jul 2008 at 11:58pm
did it work?
 
pls tel me am ahving the same problem...
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