sql 参考


[
    {
        "from":  "106.530635,29.544606",
        "to":  "126.657717,45.773225",
        "fromInfo":  "重庆",
        "toInfo":  "重庆"
    },
    {
        "from":  "113.394818,23.408004",
        "to":  "126.657717,45.773225",
        "fromInfo":  "广东",
        "toInfo":  "广东"
    },
    {
        "from":  "89.137982,31.367315",
        "to":  "126.657717,45.773225",
        "fromInfo":  "西藏",
        "toInfo":  "西藏"
    },
    {
        "from":  "114.415868,43.468238",
        "to":  "126.657717,45.773225",
        "fromInfo":  "内蒙古",
        "toInfo":  "内蒙古"
    }
]

select * from (select '106.530635,29.544606' as `from` ,'126.657717,45.773225' as `to`,'重庆' as `fromInfo`,'重庆' as `toInfo` union select '113.394818,23.408004' as `from` ,'126.657717,45.773225' as `to`,'广东' as `fromInfo`,'广东' as `toInfo` union select '89.137982,31.367315' as `from` ,'126.657717,45.773225' as `to`,'西藏' as `fromInfo`,'西藏' as `toInfo` union select '114.415868,43.468238' as `from` ,'126.657717,45.773225' as `to`,'内蒙古' as `fromInfo`,'内蒙古' as `toInfo` ) sub order by rand() LIMIT 1


select o.title,Sum(d.sum),ex.performance1,concat(format(Sum(d.sum)/ex.performance1*100,2),"%") as performance_baifen from  db_office as o
left join db_employ as e on e.oid=o.id
left join db_sell_performance as d on d.eid=e.id
left join (select ex.name,Sum(dx.sum) as performance1,ex.uid from  db_employ  as ex left join db_sell_performance as dx on ex.id=dx.eid where ex.uid=1) as ex on ex.uid=o.uid 
where o.uid=1
group by o.id
order by Sum(d.sum) desc ;


select o.title,Sum(d.performance),ex.performance1,concat(format(Sum(d.performance)/ex.performance1*100,2),"%") as performance_baifen from  db_office as o
left join db_employ as e on e.oid=o.id
left join db_dividend_log as d on d.eid=e.id
left join (select ex.name,Sum(dx.performance) as performance1,ex.uid from  db_employ  as ex left join db_dividend_log as dx on ex.id=dx.eid where ex.uid=8) as ex on ex.uid=o.uid 
where o.uid=8
group by o.id
order by Sum(d.performance) desc ;


(select 1 as s,g.id,g.goods_name,c.goods_id,IF(isnull(c.number),0,c.number) as y from db_sell_goods as g 
left join db_sell_goods_cost as c on c.goods_id = g.id
left join (select SUM(p.num) as num,p.sell_goods_id  from db_sell_performance as p where p.uid=191 group by p.sell_goods_id) as pg on pg.sell_goods_id=g.id
where g.uid=191)
union
(select 2 as s,g.id,g.goods_name,c.goods_id,(IF(isnull(c.number),0,c.number) - IF(isnull(pg.num),0,pg.num)) as y from db_sell_goods as g 
left join db_sell_goods_cost as c on c.goods_id = g.id
left join (select SUM(p.num) as num,p.sell_goods_id  from db_sell_performance as p where p.uid=191 group by p.sell_goods_id) as pg on pg.sell_goods_id= g.id
where g.uid=191)
order by id desc


select "会员" as huiyuan,SUM(l.end_money) as emoney,d2.per,concat(format((SUM(l.end_money)/d2.per*100),2),"%") as h_baifen
from card.db_member as m
left join card.db_log as l on l.mid=m.id
left join (select SUM(d.performance) as per from zq.db_employ as e left join zq.db_dividend_log as d on e.id=d.eid where e.uid=8 group by e.uid) as d2 on 1=1
where l.type=5 and m.uid=189 
group by m.uid
union
select "非会员" as fhuiyuan,SUM(l.end_money) as emoney,d2.per,concat((100-format((SUM(l.end_money)/d2.per*100),2)),"%") as h_baifen
from card.db_member as m
left join card.db_log as l on l.mid=m.id
left join (select SUM(d.performance) as per from zq.db_employ as e left join zq.db_dividend_log as d on e.id=d.eid where e.uid=8 group by e.uid) as d2 on 1=1
where l.type=5 and m.uid=189 
group by m.uid


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值