LeetCode(数据库)- 苹果和桔子

简介: LeetCode(数据库)- 苹果和桔子

题目链接:点击打开链接

题目大意:略。

解题思路:略。

AC 代码


-- 解决方案(1)
SELECT sale_date,
       SUM(CASE WHEN fruit='apples' THEN sold_num ELSE -sold_num END) AS diff
  FROM Sales
 GROUP BY sale_date
 ORDER BY sale_date
-- 解决方案(2)
SELECT sale_date, SUM(IF(fruit = 'apples', sold_num, 0)) - SUM(IF(fruit = 'oranges', sold_num, 0)) diff
FROM Sales
GROUP BY sale_date
目录
相关文章
|
缓存 NoSQL 数据库
运用云数据库 Tair 构建缓存为应用提速,完成任务得苹果音响、充电套装等好礼!
本活动将带大家了解云数据库 Tair(兼容 Redis),通过体验构建缓存以提速应用,完成任务,即可领取罗马仕安卓充电套装,限量1000个,先到先得。邀请好友共同参与活动,还可赢取苹果 HomePod mini、小米蓝牙耳机等精美好礼!
|
SQL
leetcode-SQL-1445. 苹果和桔子
leetcode-SQL-1445. 苹果和桔子
168 1
|
数据库
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
|
SQL 数据库
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
|
SQL 数据库
数据库LeetCode每日练习(一)
数据库LeetCode每日练习(一)
数据库LeetCode每日练习(一)
|
数据库
LeetCode(数据库)- 2142. The Number of Passengers in Each Bus I
LeetCode(数据库)- 2142. The Number of Passengers in Each Bus I
404 0
|
数据库
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company II
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company II
294 0
|
数据库
LeetCode(数据库)- Number of Accounts That Did Not Stream
LeetCode(数据库)- Number of Accounts That Did Not Stream
294 0
|
数据库
LeetCode(数据库)- The Airport With the Most Traffic
LeetCode(数据库)- The Airport With the Most Traffic
321 0
|
数据库
LeetCode(数据库)- The Category of Each Member in the Store
LeetCode(数据库)- The Category of Each Member in the Store
268 0