with temp as 定义变量

本文提供了一个SQL查询示例,展示如何从多个表中联接数据以获取特定组织和年级的学生详细信息,包括姓名、性别、账号等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    with temp as (select class_id, orga_id, class_name, grade  from t_class_info where orga_id = #orgaId# and grade = #grade#)
        select ac.account            ,
               ac.account_id        accountId,
               u.person_id             personId,
               u.name                name,
               u.gender                sexCode,
               decode(u.gender, '0','女','1','男','2','保密','无') sexDes,
               nvl(u.id_card_no,'无')            idNo,
               u.user_type userTypeCode,
               decode(u.user_type, '0','学生','1','老师','2','家长','3','机构','4','学校','5','学校工作人员','6','机构工作人员','7','社会学习者','8','专家','9','资源提供商','无') userTypeDes,
               ac.status             statusCode,
               decode(ac.status,'-1','注销','0','正常','1','未激活','2','锁定','3','安管锁定','无') statusDes,
               nvl(u.phone_numbers,'无') phone,
               u.job_title jobTitleCode,
               decode(u.job_title, '1','初级教师','2','中级教师','3','高级教师','无') jobTitleDes,
               nvl(u.emails, '无') email
        from t_user_group_rel re, temp, t_user u , t_account ac
        where temp.class_id = re.group_id and re.person_id = u.person_id and u.person_id = ac.person_id
        and re.status = '0'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值