From 655d8f8cfce3c839ead2da50bcb0f32d72de9402 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Tue, 14 Apr 2026 23:11:01 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20add=20'Top=20100=20=C4=91i=E1=BB=83m=20?= =?UTF-8?q?kh=E1=BB=91i=20cao=20nh=E1=BA=A5t=20-=20Long=20An'=20SQL=20pres?= =?UTF-8?q?et?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Computes each student's max admission-block sum across 49 official 2017 blocks (A00-A11, B00-B08, C00-C20, D01-D15, restricted to subjects present in our DB — no Đức/Nhật languages). One row per student, sorted by their personal best, top 100. SQL note: SQLite's MAX(x,y,...) scalar returns NULL if ANY arg is NULL. Each block expression is wrapped in COALESCE(..., -1); NULLIF(..., -1) restores NULL only for students with zero computable blocks. --- src/components/custom-query.jsx | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/components/custom-query.jsx b/src/components/custom-query.jsx index 8bf754f..6f06019 100644 --- a/src/components/custom-query.jsx +++ b/src/components/custom-query.jsx @@ -51,6 +51,73 @@ WHERE so_bao_danh LIKE '49%' AND toan IS NOT NULL AND vat_ly IS NOT NULL AND hoa_hoc IS NOT NULL ORDER BY tong_khoi_a DESC LIMIT 10`, }, + { + // Per-student MAX across 49 official 2017 blocks (A00-A11, B00-B08, + // C00-C20, D01-D15) restricted to subjects in our DB. SQLite's + // MAX(x,y,...) scalar returns NULL if ANY arg is NULL (not just all), + // so every block is wrapped in COALESCE(..., -1). NULLIF(..., -1) + // then restores NULL for students whose data yields no valid block. + label: "Top 100 điểm khối cao nhất - Long An", + sql: `SELECT + so_bao_danh, + ho_ten, + ngay_sinh, + ROUND(NULLIF(MAX( + COALESCE(toan+vat_ly+hoa_hoc, -1), -- A00 + COALESCE(toan+vat_ly+tieng_anh, -1), -- A01 + COALESCE(toan+vat_ly+sinh_hoc, -1), -- A02 + COALESCE(toan+vat_ly+lich_su, -1), -- A03 + COALESCE(toan+vat_ly+dia_ly, -1), -- A04 + COALESCE(toan+hoa_hoc+lich_su, -1), -- A05 + COALESCE(toan+hoa_hoc+dia_ly, -1), -- A06 + COALESCE(toan+lich_su+dia_ly, -1), -- A07 + COALESCE(toan+lich_su+gdcd, -1), -- A08 + COALESCE(toan+dia_ly+gdcd, -1), -- A09 + COALESCE(toan+vat_ly+gdcd, -1), -- A10 + COALESCE(toan+hoa_hoc+gdcd, -1), -- A11 + COALESCE(toan+hoa_hoc+sinh_hoc, -1), -- B00 + COALESCE(toan+sinh_hoc+lich_su, -1), -- B01 + COALESCE(toan+sinh_hoc+dia_ly, -1), -- B02 + COALESCE(toan+sinh_hoc+ngu_van, -1), -- B03 + COALESCE(toan+sinh_hoc+gdcd, -1), -- B04 + COALESCE(toan+sinh_hoc+tieng_anh, -1), -- B08 + COALESCE(ngu_van+lich_su+dia_ly, -1), -- C00 + COALESCE(ngu_van+toan+vat_ly, -1), -- C01 + COALESCE(ngu_van+toan+hoa_hoc, -1), -- C02 + COALESCE(ngu_van+toan+lich_su, -1), -- C03 + COALESCE(ngu_van+toan+dia_ly, -1), -- C04 + COALESCE(ngu_van+vat_ly+hoa_hoc, -1), -- C05 + COALESCE(ngu_van+vat_ly+sinh_hoc, -1), -- C06 + COALESCE(ngu_van+vat_ly+lich_su, -1), -- C07 + COALESCE(ngu_van+hoa_hoc+sinh_hoc, -1), -- C08 + COALESCE(ngu_van+vat_ly+dia_ly, -1), -- C09 + COALESCE(ngu_van+hoa_hoc+lich_su, -1), -- C10 + COALESCE(ngu_van+sinh_hoc+lich_su, -1), -- C12 + COALESCE(ngu_van+sinh_hoc+dia_ly, -1), -- C13 + COALESCE(ngu_van+toan+gdcd, -1), -- C14 + COALESCE(ngu_van+vat_ly+gdcd, -1), -- C16 + COALESCE(ngu_van+hoa_hoc+gdcd, -1), -- C17 + COALESCE(ngu_van+lich_su+gdcd, -1), -- C19 + COALESCE(ngu_van+dia_ly+gdcd, -1), -- C20 + COALESCE(toan+ngu_van+tieng_anh, -1), -- D01 + COALESCE(toan+ngu_van+tieng_nga, -1), -- D02 + COALESCE(toan+ngu_van+tieng_phap, -1), -- D03 + COALESCE(toan+ngu_van+tieng_trung, -1), -- D04 + COALESCE(toan+hoa_hoc+tieng_anh, -1), -- D07 + COALESCE(toan+sinh_hoc+tieng_anh, -1), -- D08 + COALESCE(toan+lich_su+tieng_anh, -1), -- D09 + COALESCE(toan+dia_ly+tieng_anh, -1), -- D10 + COALESCE(ngu_van+vat_ly+tieng_anh, -1), -- D11 + COALESCE(ngu_van+hoa_hoc+tieng_anh, -1), -- D12 + COALESCE(ngu_van+sinh_hoc+tieng_anh, -1), -- D13 + COALESCE(ngu_van+lich_su+tieng_anh, -1), -- D14 + COALESCE(ngu_van+dia_ly+tieng_anh, -1) -- D15 + ), -1), 2) AS diem_khoi_cao_nhat +FROM student +WHERE so_bao_danh LIKE '49%' +ORDER BY diem_khoi_cao_nhat IS NULL, diem_khoi_cao_nhat DESC +LIMIT 100`, + }, ], }, {