Coder Social home page Coder Social logo

liyupi / sql-mother Goto Github PK

View Code? Open in Web Editor NEW
3.1K 3.1K 355.0 2.04 MB

免费的闯关式 SQL 自学教程网站,从 0 到 1 带大家掌握常用 SQL 语法,纯前端实现,简单易学~

Home Page: http://sqlmother.yupi.icu

JavaScript 0.88% HTML 2.42% Vue 44.05% TypeScript 52.58% CSS 0.06%
css frontend html javascript sql typescript vue3 web

sql-mother's People

Contributors

coder66y avatar cq2021-coder avatar equationzhao avatar htfc786 avatar liyupi avatar ming-z-y avatar trumps4dayz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sql-mother's Issues

查询进阶 - 关联查询 - cross join

示例的查询结果和SQL代码好像不太匹配?
如果按照示例的SQL代码,跑一遍出来的结果应该是
+----------+--------+------------+---------+
| emp_name | salary | department | manager |
+----------+--------+------------+---------+
| 小明 | 5000 | 技术部 | 张三 |
| 小明 | 5000 | 技术部 | 李四 |
| 小明 | 5000 | 技术部 | 王五 |
| 李华 | 4500 | 销售部 | 张三 |
| 李华 | 4500 | 销售部 | 李四 |
| 李华 | 4500 | 销售部 | 王五 |
| 鸡哥 | 6000 | 财务部 | 张三 |
| 鸡哥 | 6000 | 财务部 | 李四 |
| 鸡哥 | 6000 | 财务部 | 王五 |
+----------+--------+------------+---------+
但这个和示例给出的结果不太相同,如果把SQL语句改成
mysql> select e.emp_name, e.salary, d.department, d.manager
-> from employees e, departments d
-> order by emp_name asc;
这样出来的结果是
+----------+--------+------------+---------+
| emp_name | salary | department | manager |
+----------+--------+------------+---------+
| 小明 | 5000 | 技术部 | 张三 |
| 小明 | 5000 | 财务部 | 李四 |
| 小明 | 5000 | 销售部 | 王五 |
| 李华 | 4500 | 技术部 | 张三 |
| 李华 | 4500 | 财务部 | 李四 |
| 李华 | 4500 | 销售部 | 王五 |
| 鸡哥 | 6000 | 技术部 | 张三 |
| 鸡哥 | 6000 | 财务部 | 李四 |
| 鸡哥 | 6000 | 销售部 | 王五 |
+----------+--------+------------+---------+
这样就和示例的结果相同了
所以问题应该是department的归属问题?

第 20 个关卡 cross join 的描述准确性

题目要求将学生表和班级表的所有行组合在一起,并返回学生姓名(student_name)、学生年龄(student_age)、班级编号(class_id)以及班级名称(class_name)。

提供的答案是 select s.name student_name, s.age student_age, s.class_id class_id, c.name class_name from student s, class c;

因为 class 表里同样有 id 字段,表示班级编号,将 s.class_id class_id 改为 c.id class_id 之后满足题目的要求,但查询结果与答案不一致,无法通过关卡。

网站数据库是什么?应该不是mysql吧?

请问该练习网站的数据库是什么?

select datetime() as 'datetime'

http://sqlmother.yupi.icu/#/learn 上面运行没有问题,

在我本地 mysql:5.7.36 上面执行报错,提示

select datetime() as 'datetime'
> 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() as 'datetime'' at line 6
> Time: 0.001s

而换成

select CURRENT_TIMESTAMP as 'datetime';

则可以得的到期待的

datetime
2023-09-26 16:15:15

第 23、24 关的子查询教学中的示例代码是否有问题?

看示例代码的时候,发现示例给的代码是跑不出来的。是否存在错误?
以下是我自己测试可以运行的代码
-- Level 23

-- My Answer of Example:
-- 主查询
SELECT c.name, o.total_amount
FROM customers c
INNER JOIN orders o ON c.customer_id = o.customer_id
WHERE c.customer_id IN (
	-- 子查询
	SELECT customer_id 
	FROM orders
	WHERE total_amount > 200
)

====================
-- Level 24

-- 主查询
SELECT c.name, o.total_amount
FROM customers c
INNER JOIN orders o ON c.customer_id = o.customer_id
WHERE EXISTS (
	-- 子查询
	SELECT DISTINCT customer_id
	FROM orders
)

第 29 关的教学

介绍“分配唯一连续排名”,介绍中却没有给出并列的例子。

能问问是什么问题呢 本地跑不动

failed to load config from C:\Users\LiWeiJun\Desktop\sql-mother-master\vite.config.ts
error when starting dev server:
Error:
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "esbuild-windows-64" package is present but this platform
needs the "esbuild-windows-32" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.

If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead of npm which has built-in support for installing a package on multiple
platforms simultaneously.

If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.

at generateBinPath (C:\Users\LiWeiJun\Desktop\sql-mother-master\node_modules\esbuild\lib\main.js:1808:17)
at esbuildCommandAndArgs (C:\Users\LiWeiJun\Desktop\sql-mother-master\node_modules\esbuild\lib\main.js:1886:33)
at ensureServiceIsRunning (C:\Users\LiWeiJun\Desktop\sql-mother-master\node_modules\esbuild\lib\main.js:2051:25)
at build (C:\Users\LiWeiJun\Desktop\sql-mother-master\node_modules\esbuild\lib\main.js:1942:26)
at bundleConfigFile (file:///C:/Users/LiWeiJun/Desktop/sql-mother-master/node_modules/vite/dist/node/chunks/dep-2faf2534.js:63043:26)
at loadConfigFromFile (file:///C:/Users/LiWeiJun/Desktop/sql-mother-master/node_modules/vite/dist/node/chunks/dep-2faf2534.js:63019:31)
at resolveConfig (file:///C:/Users/LiWeiJun/Desktop/sql-mother-master/node_modules/vite/dist/node/chunks/dep-2faf2534.js:62643:34)
at createServer (file:///C:/Users/LiWeiJun/Desktop/sql-mother-master/node_modules/vite/dist/node/chunks/dep-2faf2534.js:61943:26)
at CAC.<anonymous> (file:///C:/Users/LiWeiJun/Desktop/sql-mother-master/node_modules/vite/dist/node/cli.js:707:30)

只是过来抖个机灵。

关于level16的独特解法。
-- 请在此处输入 SQL
-- select sum(score) total_score,avg(score) avg_score,max(score) max_score,min(score) min_score from student

select 3073 as total_score,307.3 as avg_score ,600 as max_score ,0 as min_score

hhhh~~

sql 执行失败

结果

image

环境

Macbook air m2
macOS Sonoma 14.0 23A5312d arm64
node v20.5.1
npm 9.8.0
> npm list
[email protected] /Users/equationzhao/sql-mother
├── @bytemd/[email protected]
├── @bytemd/[email protected]
├── @bytemd/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── @typescript-eslint/[email protected]
├── @vitejs/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

冒险者和金币答案

SELECT adventurer_id, adventurer_name, SUM(reward_coins) AS total_reward_coins FROM rewards GROUP BY adventurer_id, adventurer_name ORDER BY total_reward_coins DESC LIMIT 3;

group by adventurer_id 也对🐔

自定义关卡-冒险者和金币

看答案中group_by adventurer_id,adventurer_name。但是adventurer_id已经是用户的唯一标识了,所以group_by adventurer_id应该就够了,没必要再加上adventurer_name了吧?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.