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

又来交作业了

627-swap-salary

https://leetcode.com/problems/swap-salary/description/

IF或者CASE

-- if和case when then else end都行
update Salary set sex = if(sex='f', 'm', 'f')
update Salary set sex = case when sex='f' then 'm' else 'f' end

1045-customers-who-bought-all-products

https://leetcode.com/problems/customers-who-bought-all-products/description/

分组之后的COUNT

-- 顾客分组之后的COUNT等于全部商品的Count
select customer_id from Customer
group by customer_id
having count(distinct (product_key)) = (select count(product_key) from Product)

1050-actors-and-directors-who-cooperated-at-least-three-times

https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/

合作过至少三次的演员和导演

-- 我还想的是用concat或者自连接呢
select actor_id, director_id
from actordirector
group by actor_id, director_id
having count(*) >= 3

1068-product-sales-analysis-i

https://leetcode.com/problems/product-sales-analysis-i/description/

-- 就这么简单?不敢相信。自己也不太熟练这里
select product_name, year, price
from Product, Sales
where Sales.product_id = Product.product_id

1070-product-sales-analysis-iii

https://leetcode.com/problems/product-sales-analysis-iii/description/

with id_first as (select product_id, min(year) as first_yearfrom Salesgroup by product_id
)select s.product_id, id_first.first_year, s.quantity, s.price
from sales s
join id_first on s.product_id = id_first.product_id and s.year = id_first.first_year;

--
WITH new AS (SELECT product_id, year, RANK() OVER (PARTITION BY product_id ORDER BY year) as rn,quantity,priceFROM Sales)
SELECT product_id, year AS first_year, quantity, price
FROM new
WHERE rn=1; 
http://www.dtcms.com/a/250078.html

相关文章:

  • 探险之物资储备c++
  • 系统设计基本功:理解语义
  • 代码随想录12|翻转单词|右旋字符串|实现strStr()|重复的子字符串
  • SCAU大数据技术原理雨课堂测验1
  • 深度解析SpringBoot自动化部署实战:从原理到最佳实践
  • TerraFE 脚手架开发实战系列(一):项目架构设计与技术选型
  • uni-app项目实战笔记12--创建分类列表完成页面跳转
  • TypeScript 类
  • 大IPD之——华为的管理变革与战略转型之道(三)
  • c++第8天--虚继承与多态
  • 使用C/C++的OpenCV 构建人脸识别并自动抓拍系统
  • 【DSP笔记 · 第3章】数字世界的“棱镜”:离散傅里叶变换(DFT)完全解析
  • AtCoder AT_abc410_e [ABC410E] Battles in a Row 题解
  • Hoppscotch
  • 解决在微信小程序中view组件下的text和images设置了样式display: flex; align-items: center;对不齐
  • 位运,模拟,分治,BFS,栈和哈希表
  • 基于 C 语言的图书管理系统开发详解​
  • 人工智能学习14-Numpy-数组广播机制
  • 前端异步编程基础
  • pythonday46
  • HTML+CSS 动态背景动态登录注册框
  • 模拟 AJAX 提交 form 表单及请求头设置详解
  • 大模型成长过程-预训练tokenizer
  • SQL Server 窗口函数详解:窗口行数控制的原理、关键字与应用场景
  • 鸿蒙NEXT-HMRouter,在使用router后无法跳转问题解决
  • 计算机网络-自顶向下—第四章网络层重点复习笔记
  • Python实例题:Python计算偏微分方程
  • 【Ubuntu 22.04 推荐的 apt 包管理方式详解】
  • HQL 优化:从低效到高效的蜕变之旅
  • Git可视化革命:3分钟学会用Mermaid+AI画专业分支图