标签:where sql HERE inf rom insert tab arc ble
ST_NAME || ST_ID || CLASS_ID || CLASS_INFO --------------------------------------------- MARK || 1 || 100 || MATH YEN || 2 || 101 || CHEM SALLY || 3 || 100 || MATH SARA || 4 || 103 || HIST
正确解法:
create table test(st_name varchar, st_id int, class_id int, class_info int);
insert into test values(‘MARK‘, 1, 100, ‘MATH‘);
insert into test values(‘YEN‘, 2, 101, ‘CHEM‘);
insert into test values(‘MARK‘, 3, 100, ‘MATH‘);
insert into test values(‘MARK‘, 4, 103, ‘HOST‘);
SELECT (MAX(counter) > 1) as sameClass FROM (SELECT COUNT(st_id) counter FROM test
WHERE ST_ID IN (1,2) GROUP BY class_info);
SELECT (MAX(counter) > 1) as sameClass FROM (SELECT COUNT(st_id) counter FROM test
WHERE ST_ID IN (1,2,3) GROUP BY class_info);
标签:where sql HERE inf rom insert tab arc ble
原文地址:https://www.cnblogs.com/gamecenter/p/11368015.html