|
select customer_id, rev,convert(char(8),purchase_date,112)as purchase_date from (
select x.customer_id,sum(x.quantity*x.actual_price)as rev,x.purchase_date
from customer_profile y inner join sales_record x
on x.customer_id=y.customer_id
where x.purchase_date=y.apply_date and x.trx_type='va'
group by x.customer_id,x.purchase_date
union
select x.customer_id,sum(x.quantity*x.actual_price)as rev,x.purchase_date
from customer_profile y inner join sales_record x
on x.customer_id=y.customer_id
where x.purchase_date>y.apply_date and x.trx_type='va'
group by x.customer_id,x.purchase_date ) a
select customer_id, rev,convert(char(8),purchase_date,112)as purchase_date from (
select x.customer_id,sum(x.quantity*x.actual_price)as rev,x.purchase_date
from customer_profile y inner join sales_record x
on x.customer_id=y.customer_id
where x.purchase_date=y.apply_date and x.trx_type='va'
group by x.customer_id,x.purchase_date
union
select x.customer_id,sum(x.quantity*x.actual_price)as rev,x.purchase_date
from customer_profile y inner merge join sales_record x
on x.customer_id=y.customer_id
where x.purchase_date>y.apply_date and x.trx_type='va'
group by x.customer_id,x.purchase_date ) a
这两个logical reads 和执行计划怎样?
[ 本帖最后由 lovexueer 于 2008-7-1 11:48 编辑 ]
|