1 Star 0 Fork 0

逸扬/leetcode-hub-mysql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc-1795.test 850 Bytes
一键复制 编辑 原始数据 按行查看 历史
逸扬 提交于 3年前 . fix lc-1795.test
# 1795. 每个产品在不同商店的价格
# https://leetcode-cn.com/problems/rearrange-products-table/
# SQL架构
Create table If Not Exists Products (product_id int, store1 int, store2 int, store3 int);
Truncate table Products;
insert into Products (product_id, store1, store2, store3) values ('0', '95', '100', '105');
insert into Products (product_id, store1, store2, store3) values ('1', '70', null, '80');
# Write your MySQL query statement below
select
product_id,
'store1' as store,
store1 as price
from
Products
where
store1 is not null
union
all
select
product_id,
'store2' as store,
store2 as price
from
Products
where
store2 is not null
union
all
select
product_id,
'store3' as store,
store3 as price
from
Products
where
store3 is not null;
# clean-up
drop table Products;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gdut_yy/leetcode-hub-mysql.git
git@gitee.com:gdut_yy/leetcode-hub-mysql.git
gdut_yy
leetcode-hub-mysql
leetcode-hub-mysql
master

搜索帮助