当前位置: 首页 > news >正文

一份sql笔试

  1. 1、
    select substr(time,1,10),count(order_id),count(distinct passenger_id)
    from order
    where substr(time,1,7)='2023-08'
    group by substr(time,1,10)
    order by substr(time,1,10);2、
    select city_id
    from
    (select * from order where substr(time,1,7) = '2022-08') t1
    left join
    (select * from passenger where sex='女') t2
    on t1.passenger_id = t2.passenger_id
    where t2.passenger_id is not null
    group by city_id
    order by count(1) desc
    limit 10;3、---第三题的count(xxx)需要好好理解,count(1)是主表总数,count(t2.xxx)则已经去除了NULL,因为count不统计NULL值
    select count(t2.passenger_id)/count(1) ratio,
    from
    (select * from passenger where substr(time_new,1,7) = '2022-08') t1 --- 8月首发的passenger_id
    left join
    (select passenger_id from order where substr(time,1,7) = '2022-09' group by passenger_id) t2  ---9月发过单的passenger_id
    on t1.passenger_id = t2.passenger_id

http://www.lryc.cn/news/45679.html

相关文章:

  • 交换瓶子
  • 二、Docker安装、启动、卸载、示例
  • 开心档之C++ STL 教程
  • Thread 类的基本用法
  • 2023.3.28 天梯赛训练赛补题(病毒溯源 , 龙龙送外卖 , 红色警报)
  • 917. 仅仅反转字母
  • Linux-Git
  • leetcode:2273. 移除字母异位词后的结果数组(python3解法)
  • 基于Python长时间序列遥感数据处理及在全球变化、物候提取、植被变绿与固碳分析、生物量估算与趋势分析等领域中的应用
  • 4.4---Spring框架之Spring事务(复习版本)
  • IP-Guard是否支持禁止客户端电脑卸载指定软件?
  • 系统图标形状overlayapk
  • 辅助编程coding的两种工具:Github Copilot、Cursor
  • MySQL5.7安装教程
  • ML@sklearn@ML流程Part3@AutomaticParameterSearches
  • Ubuntu22安装OpenJDK
  • 【数据库管理】②实例管理及数据库启动关闭
  • 【2023】Kubernetes之Pod与容器状态关系
  • LabVIEW阿尔泰PCIE 5654 例程与相关资料
  • spark2.4.4有哪些主要的bug
  • 信息学奥赛一本通 1347:【例4-8】格子游戏
  • acwing3417. 砝码称重
  • 生成式 AI:百度“文心一言”对标 ChatGPT?什么技术趋势促使 ChatGPT 火爆全网?
  • PCL 非线性最小二乘法拟合圆柱
  • 【设计模式】迪米特法则
  • CSS3笔试题精讲1
  • 交叉编译用于移植的Qt库
  • 泰凌微TLSR8258 zigbee开发环境搭建
  • C#实现商品信息的显示异常处理
  • 细数N个获取天气信息的免费 API ,附超多免费可用API 推荐(三)