当前位置:   article > 正文

sql select 嵌套select 小事例_sql select 套select

sql select 套select
SELECT x.CreateTime ,x.GoodsName  ,x.GoodsSn ,x.GoodsBref ,x.ShopPrice ,SUM(x.Num) as num,
           ShopPrice*SUM(x.Num) as totalmoney
           FROM (SELECT
           b.GoodsName,
           b.GoodsSn,
           b.GoodsBref,
           b.ShopPrice,
           a.Num,
           FROM_UNIXTIME(a.CreateTime,'%Y-%m-%d' )as CreateTime
           FROM kps_ordergoods a , kps_goods b
           where   a.GoodsId=b.GoodsId GROUP BY a.CreateTime)x
           where $condition(注意 $condition 里的条件是x.GoodsSn =""的形式 不要忘记 变量前加x. )

           GROUP BY x.CreateTime ,x.GoodsName limit 10000




select o.OrderId,o.OrderSn, FROM_UNIXTIME(o.CreateTime) as OrderTime, u.UserName, o.Consignee,
        o.Mobile, o.Address, o.OrderAmount, o.ShippingFee, o.UsedMoney, o.UsedIntegral,
        o.PayedAmount, o.FreeFee, pm.PayName  from kps_order o
        inner join kps_user u on o.UserId = u.UserId
        inner join kps_payment pm on o.PayId = pm.PayId
        where $condition GROUP BY  o.OrderSn  order by o.CreateTime limit 10000";

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/665949
推荐阅读
相关标签
  

闽ICP备14008679号