the right answerFor example,
Item_id option_id is_correct
Questions 1 a f
Item 1 b f
Questions 1 c f
Questions 1 d t
Item 2 a f
Item 2 b f
Questions 2 c f
Questions 2 d f
Please find questions 2
CodePudding user response:
Compare two sum, equal, it is not correct,Select the from st (
Select count (1) n1, st from T group by st) a
The join
(select count (1) n2, st, iscorect from T group by st, iscorect)
B
On a.s t=b.s t
Where a.n 1=2 b.n
CodePudding user response:
The select item_id from t_ems_item_option where is_correct=falseCodePudding user response:
The SELECT item_id FROM t_ems_item_option where item_id not in (SELECT item_id FROM t_ems_item_option where is_correct='t') group by item_id;CodePudding user response:
The select item_id from t_ems_item_option where is_correct='f' group by item_id having count (item_id)=4CodePudding user response:
SELECT
Item_id
The FROM t_ems_item_option
GROUP BY
Item_id
HAVING
COUNT (item_id)=COUNT (IF (is_correct='f', item_id, NULL))
CodePudding user response:
SELECT
Item_id
The FROM
T_ems_item_option
GROUP BY
Item_id
HAVING
SUM (CASE WHEN is_correct='t' END THEN 1 ELSE 0)=0