当前位置:网站首页>LeetCode-1445. Apples and oranges
LeetCode-1445. Apples and oranges
2022-06-12 06:23:00 【Border wanderer】
surface : Sales
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| sale_date | date |
| fruit | enum |
| sold_num | int |
+---------------+---------+
(sale_date,fruit) Is the primary key of the table .
This table contains... In each day " Apple " and " orange " Sales of .
Write a SQL Inquire about , Report every day Apple and orange The difference in the number of sales .
The returned result table , According to the format ('YYYY-MM-DD') Of sale_date Sort .
The query result table is shown in the following example :
Sales surface :
+------------+------------+-------------+
| sale_date | fruit | sold_num |
+------------+------------+-------------+
| 2020-05-01 | apples | 10 |
| 2020-05-01 | oranges | 8 |
| 2020-05-02 | apples | 15 |
| 2020-05-02 | oranges | 15 |
| 2020-05-03 | apples | 20 |
| 2020-05-03 | oranges | 0 |
| 2020-05-04 | apples | 15 |
| 2020-05-04 | oranges | 16 |
+------------+------------+-------------+
Result surface :
+------------+--------------+
| sale_date | diff |
+------------+--------------+
| 2020-05-01 | 2 |
| 2020-05-02 | 0 |
| 2020-05-03 | 20 |
| 2020-05-04 | -1 |
+------------+--------------+
stay 2020-05-01, sold 10 An apple and 8 An orange ( The difference is 10 - 8 = 2).
stay 2020-05-02, sold 15 An apple and 15 An orange ( The difference is 15 - 15 = 0).
stay 2020-05-03, sold 20 An apple and 0 An orange ( The difference is 20 - 0 = 20).
stay 2020-05-04, sold 15 An apple and 16 An orange ( The difference is 15 - 16 = -1).
# Write your MySQL query statement below
SELECT s1.sale_date, (s2.sold_num - s1.sold_num) as diff
FROM Sales as s1 INNER JOIN Sales as s2
ON (s1.fruit != s2.fruit AND s1.sale_date = s2.sale_date)
GROUP BY s1.sale_date边栏推荐
- About why GPU early-z reduces overdraw
- LeetCode-997. Find the town judge
- Cause analysis of motion blur / smear caused by camera shooting moving objects
- 分段贝塞尔曲线
- Multithreading (2) -- pipeline (4) -- Park and unpark
- Project progress on February 28, 2022
- English语法_副词_有无ly,意义不同
- Opencv_100问_第五章 (21-25)
- 468. verifying the IP address
- LeetCode-剑指Offer(第二版)个人题解完整版
猜你喜欢

Unity implements smooth interpolation

Houdini script vex learning

Word vector training based on nnlm

Chartextcnn (Ag dataset - news topic classification)

Jetson TX2 machine brushing jetpack4.2 (self test successful version)

MLP sensor

The vs 2019 community version Microsoft account cannot be logged in and activated offline

Simulateur nightGod ADB View log

Pytorch implementation of regression model

摄像头拍摄运动物体,产生运动模糊/拖影的原因分析
随机推荐
2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation
LeetCode-1078. Bigram participle
Research Report on truffle fungus industry - market status analysis and development prospect forecast
Unreal Engine learning notes
PDF. js FAQs
On the normalization of camera rotation interpolation
468. verifying the IP address
Cause analysis of motion blur / smear caused by camera shooting moving objects
Leetcode personal question solution (Sword finger offer3-5) 3 Duplicate number in array, 4 Find in 2D array, 5 Replace spaces
Leetcode January 12 daily question 334 Increasing ternary subsequence
Modifying theme styles in typora
(UE4 4.27) add globalshder to the plug-in
Open the camera in unity3d and display the contents of the camera in the scene as texture2d
Cross compile libev
夜神模拟器adb查看log
Multithreading Foundation (XI) -- prevent CPU from occupying 100%
SQLite cross compile dynamic library
English grammar_ Adverb_ With or without ly, the meaning is different
The first principle of thinking method
Multithreading (V) -- Concurrent tools (II) -- j.u.c concurrent contracting (I) -- AQS and reentrantlock principles