Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: crosstab Post Reply Post New Topic
Author Message
maniacneron
Newbie
Newbie


Joined: 16 Oct 2009
Online Status: Offline
Posts: 11
Quote maniacneron Replybullet Topic: crosstab
     Posted: 21 Dec 2010 at 4:35am
Hi before starting  i wanna tell you about my structure

i have 3 different tables customer,bill and coupon.

that each bill has a customerid and date.

and each coupon has a date field too.

i wanna take the count of coupons,count of  bills and count of bills grouped by customer(this gives the visit count of the customer).
i want to make crosstab that groups data in days of last week. and these would be my data. since i cannot group all data with one shared field. I cannot make this crosstab any idea would be helpful.
Thank You.
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 21 Dec 2010 at 9:24am
I am just curious is there a particular for wanting this to be a crosstab? Regardless, it seems you should be able to use a Command object, create the SQL code needed for your data and then report it as you want. I am guessing the coupon table must be related to the bill or customer table in some fashion.  If true that should give you links you need to pull the data for presentation in a group report or crosstab.
 
Regards,
 
John W.
IP IP Logged
maniacneron
Newbie
Newbie


Joined: 16 Oct 2009
Online Status: Offline
Posts: 11
Quote maniacneron Replybullet Posted: 21 Dec 2010 at 8:17pm
hi John thank you for your reply,
No particular reason for crosstab.Question is that since i have to take the counts of data i cannot take all data with one sql command and i want to group the report by  date but i don't have a shared date object each table is grouped by date but with different fields.

To summarize i want report like that:
                 visitor count     coupon count    bill count
sun          112                        456                 46

mon         456                         54                   5

tue           ..                            ..                      ..

...

how can achieve that
Thank You
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Dec 2010 at 3:49am
does the bill table have a unique identifier per row (e.g. "bill_id")?
does coupon table have the customer Id or the "bill_id" and does it have a unique identifier in it as well (e.g. "coupon_id")?


Edited by DBlank - 22 Dec 2010 at 4:00am
IP IP Logged
maniacneron
Newbie
Newbie


Joined: 16 Oct 2009
Online Status: Offline
Posts: 11
Quote maniacneron Replybullet Posted: 22 Dec 2010 at 9:36pm
yes bill table has a unique identifier  billId
yes coupon table has a customerId

and it has a uniqeu identifier as couponId
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Dec 2010 at 4:10am
Ok, I will assume that coupon and bill have no relationship to each other.
you can create a command to union Bill and coupon together to make what you need
something like
select customerid, billId as ID, date,'Bill' as Type
from bills
where datediff(day,bills.date,getdate())<8
Union
select customerid, couponId as ID, date,'Coupon' as Type
from coupons
where datediff(day,coupons.date,getdate())<8
IP IP Logged
maniacneron
Newbie
Newbie


Joined: 16 Oct 2009
Online Status: Offline
Posts: 11
Quote maniacneron Replybullet Posted: 26 Jan 2011 at 10:28pm
Hi everyone, i had postponed this issue for a while but i have to face it :)

finally i have a solution and i wanna share i hoep it helps someone

as i described my problem i need to take the sum of bills,count of bills,count of coupons,and number of visitors ad group by date.

For this i wrote and subquery that takes su of bills, count of bills  and groups by date this is subqery 1.

Another one takes the count of coupons and groups by date this is subqery 2.

last one takes the visitor count and groups by date too and this is subquery 3

then ı join these there subqery on date and select the values

select * from
subqery3 join
(select *
from
subqery1 join subqery 2 on date
group by date
) on date
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