fryguy5049
Technical User
I have crosstab query that uses a where clause to limit the data retrieved. Is there a way to add an additional column to the crosstab that isn't limited by the where clause?
Ideally I would like the results of this query as a column in the main query:
'select accstore.store ,count(date)
from store_stat
left outer join accstore on store_stat.store_number = accstore.storenum
where store_stat.super_stat='ia'
group by store
order by district,store"
Here is the main query:
select accstore.store , accstore.district,sum(cd71.amt) ,count(distinct cd71.acct) ,sum(cd71.amt)/count(distinct cd71.acct),sum(store_stat.credit_line),count(store_stat.super_stat)
from cd71, store_stat
left join accstore on accstore.merch_num=cd71.store
where store_stat.date ='2005-03-07' and cd71.acct = store_stat.acctno and cd71.date = store_stat.date
and cd71.tran = '253'
group by accstore.store
order by district,store;
Using MySQL 4.0
Ideally I would like the results of this query as a column in the main query:
'select accstore.store ,count(date)
from store_stat
left outer join accstore on store_stat.store_number = accstore.storenum
where store_stat.super_stat='ia'
group by store
order by district,store"
Here is the main query:
select accstore.store , accstore.district,sum(cd71.amt) ,count(distinct cd71.acct) ,sum(cd71.amt)/count(distinct cd71.acct),sum(store_stat.credit_line),count(store_stat.super_stat)
from cd71, store_stat
left join accstore on accstore.merch_num=cd71.store
where store_stat.date ='2005-03-07' and cd71.acct = store_stat.acctno and cd71.date = store_stat.date
and cd71.tran = '253'
group by accstore.store
order by district,store;
Using MySQL 4.0