我的查询如下:
我有一张表Table1
SkillID EmpCode
------------------------------
2 A101
4 A101
5 A101
8 A101
4 A102
3 A102
1 A102
6 A102
5 A102
7 A102
现在我必须选择没有SkillIDs 1,6和&的SELECT EmpCode。 7。 在示例中,它应该将EmpCode A101 作为结果。 仅限不包含SkillID 1,6& amp;的Empire 7应该是结果
答案 0 :(得分:2)
尝试:
SELECT EmpCode
FROM mytable
GROUP BY EmpCode
HAVING COUNT(CASE WHEN SkillID IN (1, 6, 7) THEN 1 END) = 0
您也可以使用NOT EXISTS
:
SELECT DISTINCT EmpCode
FROM mytable AS t1
WHERE NOT EXISTS (
SELECT 1
FROM mytable AS t2
WHERE t1.EmpCode = t2.EmpCode AND t2.SkillID IN (1, 6, 7) )
答案 1 :(得分:2)
以下代码位于t-sql:
{{yy, mm, dd}, {hh, mi, ss}} = :calendar.universal_time
"~.4.0w~.2.0w~.2.0wT~.2.0w~.2.0w~.2.0wZ"
|> :io_lib.format([yy, mm, dd, hh, mi, ss])
|> IO.iodata_to_binary