the query is ready. As i saw a crosstab datawindow has a grid layout. how can me make each detail to consist of two lines f.e . is it possible for a grid?
Main Topics
Browse All Topicswe hsve the following table in sql server 2000
table fsales
===========
ma1_part_num nvarchar(10)
ma1_descr nvarchar(40)
ma1_group nvarchar(03)
ma1_subgroup nvarchar(03)
ma1_sales_date datetime
ma1_sales_qty decimal(18,3)
ma1_sales_val decimal(18,3)
from an input screen user should specify month_from and month_to
and the year
output result should be like
==========================
part number jan feb mar apr may jun jul aug sep oct nov dec total
==========================
group : ggg subgroup : sss
xxxxxxxxxx 999 999 999 999 999 999 999 999 999 999 999 999 999
yyyyyyyyyy 888 888 888 888 888 888 888 888 888 888 888 888 888
==========================
totals per subgroup
==========================
totals per group
==========================
grand totals
==========================
ggg = ma1_group
sss = ma1_subgroup
xxxxxx = ma1_part_num
yyyyyy = ma1_descr
999 = sum of ma1_sales_qty
888 = sum of ma1_sales_val
(each detail consists of two lines)
the number of month columns that they will appear are related to the limits that the user specifies. f.e if month_from = 01 and month_to = 03 then only jan, feb and mar columns should be produced.
can we create an appropriate crosstab datawindow that will have the above layout?
i am using pb 11.5 and sql server 2000
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
the query is quite simple.
select
ma1_part_num,
ma1_descr,
ma1_group,
ma1_subgroup,
ma1_sales_date,
ma1_sales_qty,
ma1_sales_val
from
fmapo1
where
month(ma1_sales_date) between :from_date and :to_date
order by
ma1_group, ma1_subgroup, ma1_part_num
control (group) headers
===================
header 1 ma1_group
header 2 ma1_group, ma1_subgroup
header 3 ma1_part_num
try this...
select
ma1_part_num,
to_char(ma1_part_num),
ma1_group,
ma1_subgroup,
ma1_sales_date,
ma1_sales_qty
from
fmapo1
where
month(ma1_sales_date) between :from_date and :to_date
union all
select
ma1_part_num,
ma1_descr,
ma1_group,
ma1_subgroup,
ma1_sales_date,
ma1_sales_val
from
fmapo1
where
month(ma1_sales_date) between :from_date and :to_date
order by
ma1_group, ma1_subgroup, ma1_part_num;
Now use below in your cross tab:
rows:
1. ma1_part_num (first column in select statement)
2. ma1_part_num (second column in select statement)
columns:
month(ma1_sales_date)
values:
sum(ma1_sales_qty for crosstab)
And done, i tried with a table from sample datatabe with PowerBuilder and i got it. Let me know if you need any help. Also note that to_char function is from oracle if you are using any other database you may need to use proper function to convert numeric to character.
Regards,
Sandeep
That's very simple to solve. You need two sums in every group break right?
1. add one more column in your selet query (see third column in below query)
select
ma1_part_num,
to_char(ma1_part_num),
1,
ma1_group,
ma1_subgroup,
ma1_sales_date,
ma1_sales_qty
from
fmapo1
where
month(ma1_sales_date) between :from_date and :to_date
union all
select
ma1_part_num,
ma1_descr,
2,
ma1_group,
ma1_subgroup,
ma1_sales_date,
ma1_sales_val
from
fmapo1
where
month(ma1_sales_date) between :from_date and :to_date
order by
ma1_group, ma1_subgroup, ma1_part_num;
2. Now add that third column also in cross tab's row section
rows:
1. ma1_part_num (first column in select statement)
2. ma1_part_num (second column in select statement)
3. compute_001 (third column in select statement)
3. Now change expression for sum in group break (trailer 1 ,2 ...so on) as below
existing --> sum(ma1_sales_qty for group 1)
change as --> sum(if (compute_001 = 1, ma1_sales_qty, 0 ) for group 1)
4. copy the same and paste there hence you will have new computed column. Change it's expression as below
change as --> sum(if (compute_001 = 2, ma1_sales_qty, 0 ) for group 1)
5. Repeat the same process for all group breaks (trailer 1 ,2 ...so on) and for summary band if required.
It's possible. Let me know if you are not able to do it.
Regards,
Sandeep
Business Accounts
Answer for Membership
by: shru_0409Posted on 2009-11-02 at 05:36:36ID: 25719103
yes it is possible in powerbuilder......
what u want ???
how to create cross tab datawindow or query....???