这个是我自己写的,有大佬看下我是否有写错吗?
# 码字段为NULL情况
SELECT * FROM Table_name
WHERE '码' IS NULL;
# 父级码字段为NULL情况
SELECT * FROM Table_name
WHERE '父级码' IS NULL;
# 顶级码字段为NULL情况
SELECT * FROM Table_name
WHERE '顶级码' IS NULL;
# 码字段出现父级码或顶级码情况
SELECT * FROM Table_name
WHERE '码' NOT LIKE '瓶码%' ;
# 父级码字段出现码或者顶级码情况
SELECT * FROM Table_name
WHERE '父级码' NOT LIKE '盒码%';
# 顶级码字段出现码或者父级码情况
SELECT * FROM Table_name
WHERE '顶级码' NOT LIKE '箱码%';
# 父级码出现大于10瓶或小于10瓶的情况
SELECT '父级码', count('码') FROM Table_name
WHERE '码' IS NOT NULL OR '顶级码' IS NOT NULL
GROUP BY '父级码'
HAVING COUNT('码') != 10;
# 顶级码出现大于10箱或者小于10箱的情况
SELECT '顶级码', COUNT('父级码') FROM Table_name
WHERE '码' IS NOT NULL OR '父级码' IS NOT NULL
GROUP BY '顶级码'
HAVING COUNT('父级码') != 10;
# 顶级码出现大于100瓶或者小于100瓶的情况
SELECT '顶级码', COUNT('码') FROM Table_name
WHERE '码' IS NOT NULL OR '父级码' IS NOT NULL
GROUP BY '顶级码'
HAVING COUNT('码') != 100;
学到了,还能用 GPT 来弄,我也弄个账号看看