供参考:

SELECT
r.course_id 课程id,
r.user_id 用户ID,
u.user_full_name 姓名,
u.province_name 省名,
u.city_name 城市,
c.card_password 兑换码,
o.order_id 订单,
o.real_fee 实付金额,
o.order_type 订单类型,
o.pay_type 支付方式,
o.device_type 设备类型,
o.order_status 订单状态,
(case when c.user_id is null and o.user_id is null then '有权限无来源' when o.order_status='已退款' then '有权限无来源' when c.card_password is not null then '兑换码' when o.user_id is not null then '订单' else '' end) 状态检查
from
(
select distinct a.course_id,a.user_id,b.sku_id goods_id,a.order_id
from tetralogy.user_rights_course a left join tetralogy.goods_sku_course b on b.course_id=a.course_id
where a.current_status='1'
) r
left join
(
select
card_unlock_user_id user_id,
card_password,
goods_id
from tetralogy.card_info
where 1=1
and card_is_unlock=0
and card_is_valid=1
) c on r.user_id=c.user_id and r.goods_id=c.goods_id
left join
(
select
user_id,id order_id,goods_ids goods_id,device_type,real_fee,
(case order_type when 0 then '课程' when 1 then '解锁码' else order_type end ) order_type,
(case pay_type when 0 then '微信' when 1 then '支付宝' when 2 then '苹果' when 3 then '对公转账' else order_type end ) pay_type,
(case order_status when 0 then '待支付' when 1 then '已支付' when 2 then '退款中' when 3 then '已退款' when 9 then '已关闭' else order_status end ) order_status
from tetralogy.app_order
where order_status=1
) o on r.order_id=o.order_id
left join tetralogy.user_info u on u.id=r.user_id
where 1=1

  

复杂SQL案例:用户授权渠道查询的更多相关文章

  1. SQL server 语句新建用户、对用户授权、删除用户实例

    Grant select on tb to db_user --给db_user用户授权 tb表 查询权限 一.命令操作 USE mydb GO --1. 新建测试用户 --1.1 添加登录用户和密码 ...

  2. Oracle创建用户并给用户授权查询指定表或视图的权限

    MSV31账户登录数据库进行如下操作: CREATE USER NORTHBOUND IDENTIFIED BY NORTHBOUND  DEFAULT TABLESPACE "TBS_DN ...

  3. 转://Oracle A用户给B用户授权查询指定表或视图权限方案

    用DNINMSV31账户登录数据库进行如下操作: CREATE USER NORTHBOUND IDENTIFIED BY NORTHBOUND DEFAULT TABLESPACE "TB ...

  4. oracle常用SQL——创建用户、表空间、授权(12C)

    一.查询 查询用户所属 表空间 select username,default_tablespace from dba_users where username='xxx' 查询表空间情况 SELEC ...

  5. 阶段5 3.微服务项目【学成在线】_day18 用户授权_07-动态查询用户权限-权限数据模型

    3 动态查询用户权限 3.1 需求分析 截至目前在测试授权时使用的权限数据是静态数据,正常情况的流程是: 1.管理员给用户分配权限,权限数据写到数据库中. 2.认证服务在进行用户认证时从数据库读取用户 ...

  6. mysql用户授权、数据库权限管理、sql语法详解

    mysql用户授权.数据库权限管理.sql语法详解 —— NiceCui 某个数据库所有的权限 ALL 后面+ PRIVILEGES SQL 某个数据库 特定的权限SQL mysql 授权语法 SQL ...

  7. MYSQL语句:创建、授权、查询、修改、统计分析等 一 用户的创建、权限设置、删除等

    MYSQL语句:创建.授权.查询.修改.统计分析.. 一.用户的创建.权限设置.删除等 1.首先链接MySQL操作 连接格式:mysql -h 主机地址 -u 用户名 -p 用户密码 (注-u与roo ...

  8. 三十二. 多表查询 MySQL管理工具 、 用户授权及撤销

    1.MySQL管理工具 部署LAMP+phpMyAdmin平台 安装httpd.mysql.php-mysql及相关包 启动httpd服务程序 解压phpMyAdmin包,部署到网站目录 配置conf ...

  9. 阶段5 3.微服务项目【学成在线】_day18 用户授权_08-动态查询用户的权限-用户中心查询用户权限

    3.3 用户中心查询用户权限 3.3.1 需求分析 认证服务请求用户中心查询用户信息,用户需要将用户基本信息和用户权限一同返回给认证服务. 本小节实现用户查询查询用户权限,并将用户权限信息添加到的用户 ...

随机推荐

  1. CentOS7部署ceph

    CEPH 简介 不管你是想为云平台提供Ceph 对象存储和/或 Ceph 块设备,还是想部署一个 Ceph 文件系统或者把 Ceph 作为他用,所有 Ceph 存储集群的部署都始于部署一个个 Ceph ...

  2. phpMyAdmin简介及安装

    phpMyAdmin是一个MySQL数据库管理工具,通过Web接口管理数据库方便快捷. Linux系统安装phpMyAdmin phpMyAdmin是一个MySQL数据库管理工具,通过Web接口管理数 ...

  3. Excel-判断一个文本字符串中是否包含数字! 判断一个文本字符串是否是纯汉字!

    0.判断一个文本字符串中是否包含数字!/判断一个文本字符串是否是纯汉字! 公式=IF(LENB(A1)=2*LEN(A1),"都是汉字","含有非汉字字符") ...

  4. Oracle-trunc函数、round 函数、ceil函数和floor函数---处理数字函数使用

    0.round函数 按照指定小数位数进行四舍五入运算. SELECT ROUND( number, [ decimal_places ] ) FROM DUAL #number : 待处理数值  de ...

  5. Kubernetes主机间cluster ip时通时不通

    1.问题现象 测试部署了一个service,包括2个pod,分别在node1和node2上. $ kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) ...

  6. Spring Boot 热启动插件

    1. maven依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId ...

  7. A Child's History of England.26

    CHAPTER 9 ENGLAND UNDER WILLIAM THE SECOND, CALLED RUFUS William the Red, in breathless haste, secur ...

  8. C++ 德才论

    输入样例: 14 60 80 10000001 64 90 10000002 90 60 10000011 85 80 10000003 85 80 10000004 80 85 10000005 8 ...

  9. oralce 存储过程传入 record 类型的参数?

    先定义一个 package , package中含有一个 record 类型的变量 create or replace package pkg_record is type emp_record is ...

  10. SpringMVC(1):SpringMVC入门

    一,MVC 概述 MVC:模型,视图,控制器,是一种软件设计规范,本质是将业务逻辑,数据,显示,分离的方式来编写代码:前后端分离 Model:数据模型,提供要展示的数据,一般我们都会把这两个分离开来. ...