あなたの質問:
SELECT Email, Phonenumber
FROM EMPLOYEE
WHERE COUNT(
ID = (SELECT ID_Num
FROM SCHEDULE
WHERE Start_Time <= 12:07 AND End_Time >= 12:07)
AND Shopn = (SELECT Shopname
FROM SHOP
WHERE Shoptype = ‘market’) ) > 2
問題:
- 「=」演算子を使用してIDを選択しようとしているようですが、内部クエリによって複数のエントリが返された場合は失敗します。
- where句に集計演算子を追加することはできません。
考えられる答え:
select Email, Phonenumber
FROM EMPLOYEE
WHERE ID in (SELECT ID_Num
FROM SCHEDULE
WHERE Start_Time <= '12:07' AND End_Time >= '12:07')
AND Shopn in (SELECT Shopname
FROM SHOP
WHERE Shoptype = 'market')
and (
select count(distinct id)
FROM EMPLOYEE
WHERE ID in (SELECT ID_Num
FROM SCHEDULE
WHERE Start_Time <= '12:07' AND End_Time >= '12:07')
AND Shopn in (SELECT Shopname
FROM SHOP
WHERE Shoptype = 'market')) > 2;