1. 经销商 按店铺交易量汇总

select i.shop_id,i.shop_name,u.real_name,u.mobile,nvl(p.summary,0) from bp_shop_info i left join
(
select t.shop_id,sum(t.shop_cost) as summary from bp_platform_order t
where t.request_time >= to_date('2014-**','yyyy-mm')
and t.request_time < to_date('2014-**','yyyy-mm')
and t.spreader_id=10210
and t.order_status in (0,91)
group by t.shop_id) p
on i.shop_id=p.shop_id
left join bp_system_user u on i.shop_owner=u.user_id
where i.spreader_id=10210

交易量汇总

 select e.nickname staff,i.shop_name, u.real_name, u.mobile, nvl(p.summary, 0) total_order_fee
from bp_shop_info i
left join (select t.shop_id, sum(t.order_fee) as summary
from bp_platform_order t
where t.request_time >= to_date('2014-04', 'yyyy-mm')
and t.request_time < to_date('2014-05', 'yyyy-mm')
and t.spreader_id = 10210
and t.order_status in (0, 91)
and t.business_type in ('G3')
group by t.shop_id) p on i.shop_id = p.shop_id
left join bp_system_user u on i.shop_owner = u.user_id
left join bp_spreader_employee e on i.spreaders_staff_id=e.user_id
left join bp_system_spreader s on i.spreader_id=s.user_id
left join bp_system_user u2 on s.user_id=u2.user_id
where i.spreader_id = 10210
order by i.shop_id desc

按业务统计

张勇

 select u2.real_name 推广人, i.shop_name 店铺名称, u.real_name 店主姓名, u.mobile 店主电话, nvl(p.summary, 0) 总交易量
from bp_shop_info i
left join (select t.shop_id, sum(t.shop_cost) as summary
from bp_platform_order t
where t.request_time >= to_date('2014-07', 'yyyy-mm')
and t.request_time < to_date('2014-08', 'yyyy-mm')
and t.spreader_id = 10210
and t.order_status in (0, 91)
and t.business_type in ('Huafei','Guhua')
group by t.shop_id) p on i.shop_id = p.shop_id
left join bp_system_user u on i.shop_owner = u.user_id
left join bp_system_user u2 on i.spreaders_staff_id = u2.user_id
where i.spreader_id = 10210
and i.create_time >= to_date('2014-07', 'yyyy-mm')
and i.create_time < to_date('2014-08', 'yyyy-mm')
order by i.shop_id desc

张勇_新开店铺话费交易量汇总

2. 供货商 查询供货商的订单列表

 select t.platform_order_id,
t.finish_time,
t.product_name,
i.shop_name,
u.real_name,
t.system_cost,
t.platform_cost,
t.spreader_cost,
t.shop_cost,
t.shop_pay_fee
from bp_platform_order t
inner join bp_shop_info i on t.shop_id = i.shop_id
inner join bp_system_user u on t.spreader_id = u.user_id
where t.supplier_id = 15240
and t.spreader_id = 15240
and t.finish_time >= to_date('2014-**', 'yyyy-mm')
and t.finish_time < to_date('2014-**', 'yyyy-mm')
and t.order_status = 0
order by t.product_name desc

供货商订单列表

 select u.real_name         供货商,
t.platform_order_id 订单号,
t.finish_time 订单完成时间,
t.product_name 商品名称,
i.shop_name 店铺名称,
t.system_cost 供货商家成本,
t.spreader_cost 经销商成本,
t.shop_cost 店铺成本,
t.shop_pay_fee 店铺支付金额,
t.order_num 总件数,
t.logistics_fee 运费
from bp_platform_order t
inner join bp_shop_info i on t.shop_id = i.shop_id
inner join bp_system_user u on t.spreader_id = u.user_id
where t.supplier_id = 10210
and t.spreader_id = 10210
and t.finish_time >= to_date('2014-06-18', 'yyyy-mm-dd')
and t.finish_time < to_date('2014-08-01', 'yyyy-mm-dd')
and t.success_fee > 0
and t.order_status = 0
order by t.finish_time asc

张勇_货款结算

3. 经销商 按店铺统计 实物商品的交易笔数

 select e.nickname staff,i.shop_name, u.real_name, u.mobile, nvl(p.summary, 0) total_order_fee
from bp_shop_info i
left join (select t.shop_id, count(t.platform_order_id) as summary
from bp_platform_order t
inner join bp_goods_order_details d on t.platform_order_id=d.order_no
where t.request_time >= to_date('2014-04', 'yyyy-mm')
and t.request_time < to_date('2014-05', 'yyyy-mm')
and t.spreader_id = 10210
and t.order_status in (0, 91)
and d.sku_id=5
group by t.shop_id) p on i.shop_id = p.shop_id
left join bp_system_user u on i.shop_owner = u.user_id
left join bp_spreader_employee e on i.spreaders_staff_id=e.user_id
left join bp_system_spreader s on i.spreader_id=s.user_id
left join bp_system_user u2 on s.user_id=u2.user_id
where i.spreader_id = 10210
order by i.shop_id desc

交易笔数

4. 供货商结算(扣除平台钱包)

sp_pay_bianmin_withdraw

5. 店铺交易量汇总

  * Pur:统计各产品线交易量,按店铺汇总
  * Frm:来自张勇的需求

  temp_rpt_sales_shop

6. 根据手机号码或姓名查用户相关角色及信息

select (case nvl(e.role_id, -1)
when 0 then
'经销商'
when 1 then
'推广人'
when -1 then
'/'
else
'经销商员工'
end) || '[' || nvl(e.se_id, -1) || ']' "经销商(SEID)",
nvl(si.name, '/') || '[' || nvl(si.suppiler_id, -1) || ']' "供货商[SUID]",
decode(se.role_id, 0, '店主', '店员') || '[' || i.shop_id || ']' "代理商[SHOPID]",
u.user_name || '[' || u.mobile || ']' "登陆名[手机]",
u.real_name || '[' || u.user_id || ']' "真名[UID]",
u2.real_name || '[' || u2.user_id || ']' 所属经销商,
u3.real_name || '[' || u3.user_id || ']' 所属推广人
from bp_system_user u
left join bp_shop_info i on u.shop_id = i.shop_id
left join bp_shop_employee se on u.user_id = se.user_id
left join bp_spreader_employee e on u.user_id = e.user_id
left join bp_supplier_info si on u.user_id = si.user_id
left join bp_system_user u2 on i.spreader_id = u2.user_id
left join bp_system_user u3 on i.spreaders_staff_id = u3.user_id
where u.real_name = ''
or u.mobile = ''
or u.user_name = ''

根据手机号码或姓名查用户相关角色及信息

7. 查询某天各个时段的充值量

select to_char((trunc(sysdate) +
trunc((o.request_time - trunc(sysdate)) * 24 * 60 / 30) * 30 / 60 / 24),
'hh24:mi') || '-' ||
to_char((trunc(sysdate) +
trunc((o.request_time - trunc(sysdate)) * 24 * 60 / 30 + 1) * 30 / 60 / 24),
'hh24:mi') period,
count(*) 订单笔数,
sum(o.order_fee) 订单总面值,
sum(o.success_fee) 成功总面值
from bp_platform_order o
where o.request_time >= to_date('', 'yyyymmdd')
and o.request_time < to_date('', 'yyyymmdd') + 1
group by to_char((trunc(sysdate) +
trunc((o.request_time - trunc(sysdate)) * 24 * 60 / 30) * 30 / 60 / 24),
'hh24:mi') || '-' ||
to_char((trunc(sysdate) +
trunc((o.request_time - trunc(sysdate)) * 24 * 60 / 30 + 1) * 30 / 60 / 24),
'hh24:mi')
order by 1;

8. 店铺通过资金变动和当天店铺交易报表中的成本来计算的当天资金消耗

公式:

x 当天计算的消费金额 = 第二天的余额 - 前一天的余额

y 当天店铺计算的订单成本 = 当天已完成订单的成本合计

y = x + (当天以前下的订单,当天完成的订单成本总计[SQL1]) - (当天下的订单,当天以后完成的订单成本总计[SQL2])

SQL1:

select * from bp_platform_order o
where o.request_time < to_date('','yyyymmdd')
and o.finish_time >= to_date('','yyyymmdd')
and o.finish_time < to_date('','yyyymmdd')
and o.shop_id=104652

SQL2:

select * from bp_platform_order o
where o.request_time >= to_date('','yyyymmdd')
and o.request_time < to_date('','yyyymmdd')
and o.finish_time >= to_date('','yyyymmdd')
and o.shop_id=104652

常用SQL语句(工作)的更多相关文章

  1. php面试专题---MySQL常用SQL语句优化

    php面试专题---MySQL常用SQL语句优化 一.总结 一句话总结: 原理,万变不离其宗:其实SQL语句优化的过程中,无非就是对mysql的执行计划理解,以及B+树索引的理解,其实只要我们理解执行 ...

  2. 常用SQL语句大全

    一些常用SQL语句大全   一.基础1.说明:创建数据库CREATE DATABASE database-name2.说明:删除数据库drop database dbname3.说明:备份sql se ...

  3. Mysql常用sql语句(14)- 多表查询

    测试必备的Mysql常用sql语句,每天敲一篇,每次敲三遍,每月一循环,全都可记住!! https://www.cnblogs.com/poloyy/category/1683347.html 前言 ...

  4. Mysql常用sql语句(21)- regexp 正则表达式查询

    测试必备的Mysql常用sql语句系列 https://www.cnblogs.com/poloyy/category/1683347.html 前言 正则的强大不言而喻,Mysql中也提供了 reg ...

  5. Mysql常用sql语句(6)- limit 限制查询结果的条数

    测试必备的Mysql常用sql语句系列 https://www.cnblogs.com/poloyy/category/1683347.html 前言 实际工作中,我们的数据表数据肯定都是万级别的,如 ...

  6. Mysql 常用 SQL 语句集锦

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  7. Mysql 常用 SQL 语句集锦 转载(https://gold.xitu.io/post/584e7b298d6d81005456eb53)

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  8. 50个常用SQL语句

    50个常用SQL语句 Student(S#,Sname,Sage,Ssex) 学生表  S#学号,主键 Course(C#,Cname,T#) 课程表          C#课程号,主键 SC(S#, ...

  9. oracle sqlplus及常用sql语句

    常用sql语句 有需求才有动力 http://blog.csdn.net/yitian20000/article/details/6256716 常用sql语句 创建表空间:create tables ...

随机推荐

  1. android 入门-Service

    sdk 1.7 package com.example.hellowrold; import java.util.Random; import com.example.hellowrold.R.id; ...

  2. hdu 3032 sg打表找规律 *

    有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 打表代码: #include ...

  3. 在CentOS中快速安装PHP,MySQL,Nginx和phpMyAdmin

    安装环境 yum install -y autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel vim 安装p ...

  4. SpringMyBatis解析3-MapperFactoryBean

    在使用mybatis的时候,我们获取dao的方式一般是这样: SqlSession session=sessionFactory.openSession(); PersonDao personDao= ...

  5. 《DSP using MATLAB》示例Example5.2

    代码: L = 5; N = 20; k = [-N/2:N/2]; % square wave parameters xn = [ones(1,L), zeros(1,N-L)]; % Sq wav ...

  6. 仓库、超市、服装、食品、批发零售手持打印PDA开单器-现场无线开单扫描 无线传输电脑

    深圳浩瀚技是一家主要从事手持数据终端硬件.软件研究.销售服务为一体的高新企业公司.公司主要销售进销存等无线开单系统.工业级手持PDA,安卓数据采集器,RFID阅读器等设备.我们秉承“诚信.敏捷.繁荣” ...

  7. 1140 分珠 dfs

    时间限制:500MS  内存限制:65536K提交次数:24 通过次数:18 题型: 编程题   语言: G++;GCC Description 如下图所示,有若干珠子,每颗珠子重量不同,珠子之间有一 ...

  8. Python基础8- 序列

    序列是一组有顺序的元素的集合序列的成员是有序排列的且可以通过下标偏移量来访问它的一个或几个成员序列可以包含一个或多个元素,也可以没有任何元素序列有两种类型:列表(list)和元组(tuple),两者的 ...

  9. qq邮箱邮我组件

    http://openmail.qq.com/cgi-bin/qm_help_mailme?sid=uvkgSu7e0aOrc0Qc&t=open_mailme 邮我 使用"邮我&q ...

  10. POJ3184 Ikki's Story I - Road Reconstruction(最大流)

    求一次最大流后,分别对所有满流的边的容量+1,然后看是否存在增广路. #include<cstdio> #include<cstring> #include<queue& ...