小小小小小小白瓜 2022-12-02 11:18 采纳率: 100%
浏览 42
已结题

求解以下两个SQL的代码

img

img


想知道以上两个问题的sql代码该如何续写!
想知道以上两个问题的sql代码该如何续写!

  • 写回答

1条回答 默认 最新

  • AllenGd 大数据领域优质创作者 2022-12-02 12:38
    关注
    第一题:
    select  id ,replace (group_concat(value1),',','') value1,replace (group_concat(value2),',','') value2
    from A
    group by id;
    
    第二题:
    select name,a.score,`leave` from (
    select name,sum(score) score from (
    select id,name,c_city,score from (SELECT a.id,a.name,a.city,
    SUBSTRING_INDEX( SUBSTRING_INDEX( SUBSTRING(city, LOCATE('[', city)+1,LOCATE(']', city)-2), ',', b.help_topic_id + 1 ), ',',- 1 ) c_city
    FROM test.A a
    JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( a.city ) - LENGTH( REPLACE ( a.city, ',', '' ) ) + 1 )) a 
    left join test.B b 
    on a.c_city = b.city ) a 
    group by name
    ) a 
    left join (select score,`leave`,cast(score_min as SIGNED ) score_min,cast(score_max as SIGNED) score_max from (
    select *,LOCATE('~', score),substr(score,1,LOCATE('~', score)-1) score_min, substr(score,LOCATE('~', score)+1,length(score)) score_max
    from test.C ) a) b 
    on b.score_min <= a.score
    and a.score < b.score_max
    order by name;
    

    详细步骤:https://blog.csdn.net/Allenzyg/article/details/128146788?spm=1001.2014.3001.5502

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 12月11日
  • 已采纳回答 12月3日
  • 创建了问题 12月2日

悬赏问题

  • ¥50 苹果MGIE项目部署缺少emb权重
  • ¥15 采用ansys进行机翼在特定路径下的打孔过程中的受力分析
  • ¥15 单片机adb主机连接手机,usb调试密钥无法保存
  • ¥15 已知X和Y有以下关系,求X和Y的关系式
  • ¥15 net core 同时编辑怎么防止数据多保存了
  • ¥15 matlab做ba模型让其在ba和er规则下生长
  • ¥50 有偿!centos curl port设置问题
  • ¥15 请问Quartus的Verilog代码怎么写?
  • ¥100 Mac 版foxmail 收邮件问题
  • ¥15 QWebEngineView