select
//订单信息
_t6040.tf_ordersId as tf_ordersId ,
_t6040.tf_ordersNumber as tf_ordersNumber ,
_t6040.tf_date as tf_date ,
_t6040.tf_finished as tf_finished ,
_t6040.tf_remark as tf_remark ,
( select //订单数量求和
sum(_t6050.tf_number)
from
OrdersDetail _t6050
left outer join
Orders _child_t6040
on _child_t6040.tf_ordersId = _t6050.tf_ordersId
left outer join
Product _t6030
on _t6030.tf_productId = _t6050.tf_productId
where //附加在订单明细上面的 商品的条件
_t6030.tf_productId in (
'1','2','3','4','5','6'
)
and _child_t6040.tf_ordersId = _t6040.tf_ordersId ) as S__t6050___tf_number ,
( select
sum(_t6050.tf_subtotalPrice)
from
OrdersDetail _t6050
left outer join
Orders _child_t6040
on _child_t6040.tf_ordersId = _t6050.tf_ordersId
left outer join
Product _t6030
on _t6030.tf_productId = _t6050.tf_productId
where
_t6030.tf_productId in (
'1','2','3','4','5','6'
)
and _child_t6040.tf_ordersId = _t6040.tf_ordersId ) as S__t6050___tf_subtotalPrice
from
Orders _t6040 //订单表
left outer join
Customer _t6010 //客户表
on _t6010.tf_customerId = _t6040.tf_customerId
where
// 附加在订单之上的 客户条件
_t6010.tf_customerId in (
'1','2','3','4','5','6','7','8'
)
看起来还不算太难,因为这里只选择了2张表的字段,如果选择了10张表,20张表呢?一直跟着我的博客看的,可以想一想这个问题,一个条件可以加在基准模块之上,加在聚合字段之上,还会出现有什么情况?