I need to build a sales tax report that needs three elements
1. gross sales over the entire biz,
2. gross sales in the specific state
3. Taxed Sales in the specific state
I have three different queries that generate these elements . How do I combine the different sums into one table?
------3. Taxed Sales in the specific state
select 'dbr.crosstab', 'Order State'; select 'dbr.hdr', 'Year', 'Month'; select 'dbr.sum', 'Taxed Gross Sales (In State)','Sales Tax Collected'; select 'dbr.colstyle', 'Year', mydbr_style('NumAsStr');
select
year (a.date/time
) as 'Year',
MONTHNAME(STR_TO_DATE(Month (a.date/time
),'%m') )as 'Month',
a.type
as 'Order Type',
a.order state
as 'Order State',
sum(a.Product Sales
) as 'Taxed Gross Sales (In State)',
sum(a.sales tax collected
) as 'Sales Tax Collected'
from dsguru_eBayMadeEasy.AzTransactionRpts a
inner join dsguru_eBayMadeEasy.users u on u.cid = a.cid
where (a.type = 'Order' or a.type = 'Refund') and a.sales tax collected
<> 0 and u.username = inLogin
group by year
,Month (a.date/time
) , a.type
, a.order state
order by year
desc,Month (a.date/time
) desc , a.type
;
------ 2. gross sales in the specific state
select 'dbr.crosstab', 'Order State';
select 'dbr.hdr', 'Year';
select 'dbr.hdr', 'Month';
select 'dbr.sum', 'Gross Sales (in state)','Sales Tax Collected';
select 'dbr.colstyle', 'Year', mydbr_style('NumAsStr');
select
year (a.date/time
) as 'Year',
MONTHNAME(STR_TO_DATE(Month (a.date/time
),'%m') )as 'Month',
a.type
as 'Order Type',
a.order state
as 'Order State',
sum(a.Product Sales
) as 'Gross Sales (in state)',
sum(a.sales tax collected
) as 'Sales Tax Collected'
from dsguru_eBayMadeEasy.AzTransactionRpts a
inner join dsguru_eBayMadeEasy.users u on u.cid = a.cid
where (a.type = 'Order' or a.type = 'Refund') and u.username = inLogin and (a.Order State
= 'CA' or a.Order State
= 'FL' or a.Order State
= 'TX')
group by year
,Month (a.date/time
) , a.type
, a.order state
order by year
desc,Month (a.date/time
) desc , a.type
;
----- 1. gross sales over the entire biz, select 'dbr.hdr', 'Year'; select 'dbr.hdr', 'Month'; select 'dbr.sum', 'Gross Sales (all locations)','Sales Tax Collected'; select 'dbr.colstyle', 'Year', mydbr_style('NumAsStr');
select
year (a.date/time
) as 'Year',
MONTHNAME(STR_TO_DATE(Month (a.date/time
),'%m') )as 'Month',
a.type
as 'Order Type',
sum(a.Product Sales
) as 'Gross Sales (all locations)',
sum(a.sales tax collected
) as 'Sales Tax Collected'
from dsguru_eBayMadeEasy.AzTransactionRpts a
inner join dsguru_eBayMadeEasy.users u on u.cid = a.cid
where (a.type = 'Order' or a.type = 'Refund') and u.username = inLogin
group by year
,Month (a.date/time
) , a.type
order by year
desc,Month (a.date/time
) desc , a.type
;
Thanks In Advance