坏人未变坏 2017-07-21 07:19 采纳率: 0%
浏览 1372
已采纳

如何将三段sql语句存到一个结果集中返回?

这是我的SQL语句:

             select
                                    a.amount as suixi_money,
                                    a.amodanaTime as suixi_tiem,
                                    a.registerMobile as principal_tel_number,
                                    b.type as activity_type,
                                    c.name as query_nickname,
                                    c.mobile as query_tel_number,
                                    c.realName as query_name
                               from tb_activity_record a
                                left join tb_activity b on a.activityId = b.id
                                left join tb_member c on a.memberId = c.id
                        where 1=1
                                and b.uid = '8445e6a4-9341-455b-bfef-81e0b5ed7a1e'
                                and  (
                                c.name like '1%'
                                or c.realName like '1%'
                                or c.mobile like '1%'
                                 )

                            select count(*) from (select distinct memberId from tb_activity_record ) ac


                            select SUM(amount) from tb_activity_record

这三段:
图片说明

万分感谢

  • 写回答

12条回答 默认 最新

  • Nothing_katu 2017-07-21 09:50
    关注
     SELECT
        A .amount AS suixi_money,
        A .amodanaTime AS suixi_tiem,
        A .registerMobile AS principal_tel_number,
        b. TYPE AS activity_type,
        c. NAME AS query_nickname,
        c.mobile AS query_tel_number,
        c.realName AS query_name,
    ac.count,
    su.SUM
    FROM
    (select count(*) count from (select distinct memberId from tb_activity_record ) d) ac,
    (select SUM(amount)  SUM from tb_activity_record) su,
        tb_activity_record A
    LEFT JOIN tb_activity b ON A .activityId = b. ID
    LEFT JOIN tb_member c ON A .memberId = c. ID
    
    WHERE
        1 = 1
    AND b. UID = '8445e6a4-9341-455b-bfef-81e0b5ed7a1e'
    AND (
        c. NAME LIKE '1%'
        OR c.realName LIKE '1%'
        OR c.mobile LIKE '1%'
    )
    

    你第一段sql查不出数据啊?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(11条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。
  • ¥15 抖音看过的视频,缓存在哪个文件