当前位置: 首页 > 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; 

相关文章:

  • 探险之物资储备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
  • 动态网站开发相关技术/百度推广优化方案
  • 网站做聚合页面方案如何写/seo自然排名
  • 南昌做网站kaiu/陕西网页设计
  • 做网站的zk啥/汕头seo优化培训
  • 手机微信可以做网站吗/百度云搜索引擎入口官方
  • 电商培训内容有哪些/seo网络优化前景怎么样