75 lines
1.6 KiB
SQL
75 lines
1.6 KiB
SQL
-- ============================================
|
|
-- 详细检查出国登记数据
|
|
-- ============================================
|
|
|
|
-- 1. 查看所有字段的数据(包括deleted字段)
|
|
SELECT
|
|
registration_id,
|
|
name,
|
|
gender,
|
|
department,
|
|
status,
|
|
registration_time,
|
|
tenant_id,
|
|
deleted,
|
|
create_time,
|
|
update_time
|
|
FROM rs_overseas_registration
|
|
ORDER BY create_time DESC
|
|
LIMIT 20;
|
|
|
|
-- 2. 统计deleted字段的分布
|
|
SELECT
|
|
deleted,
|
|
CASE deleted
|
|
WHEN '0' THEN '未删除'
|
|
WHEN '1' THEN '已删除'
|
|
ELSE '异常值'
|
|
END as deleted_text,
|
|
COUNT(*) as count
|
|
FROM rs_overseas_registration
|
|
GROUP BY deleted;
|
|
|
|
-- 3. 统计tenant_id的分布
|
|
SELECT
|
|
tenant_id,
|
|
COUNT(*) as count
|
|
FROM rs_overseas_registration
|
|
GROUP BY tenant_id;
|
|
|
|
-- 4. 检查registration_time是否为NULL
|
|
SELECT
|
|
COUNT(*) as total_count,
|
|
SUM(CASE WHEN registration_time IS NULL THEN 1 ELSE 0 END) as null_count,
|
|
SUM(CASE WHEN registration_time IS NOT NULL THEN 1 ELSE 0 END) as not_null_count
|
|
FROM rs_overseas_registration
|
|
WHERE deleted = '0';
|
|
|
|
-- 5. 查看最近新增的数据(未删除的)
|
|
SELECT
|
|
registration_id,
|
|
name,
|
|
gender,
|
|
department,
|
|
position,
|
|
status,
|
|
registration_time,
|
|
tenant_id,
|
|
deleted,
|
|
create_time
|
|
FROM rs_overseas_registration
|
|
WHERE deleted = '0'
|
|
ORDER BY create_time DESC
|
|
LIMIT 10;
|
|
|
|
-- 6. 检查是否有registration_time为NULL的记录
|
|
SELECT
|
|
registration_id,
|
|
name,
|
|
registration_time,
|
|
create_time
|
|
FROM rs_overseas_registration
|
|
WHERE deleted = '0'
|
|
AND registration_time IS NULL;
|
|
|