SQL SELECT项目,而不字符

我有以下SQL:SQL SELECT项目,而不字符

SELECT 

M.*

FROM

(

SELECT MAX(counter) AS FirstUserDate, imdb_id, language, season, aufloesung, episode

FROM autofehlerserie

GROUP BY imdb_id, language

) foo

JOIN

autofehlerserie M ON foo.imdb_id = M.imdb_id AND foo.language = M.language

ORDER BY

foo.FirstUserDate DESC, M.imdb_id, M.aufloesung, cast(M.season as int), cast(M.episode as int)

但我只想要SELECT items WHERE marker not = "D"

在那里我有添加此此select查询?

回答:

使用它象下面这样:

SELECT 

M.*

FROM

(

SELECT MAX(counter) AS FirstUserDate, imdb_id, language, season, aufloesung, episode

FROM autofehlerserie

WHERE marker <> 'D'

GROUP BY imdb_id, language, season, aufloesung, episode

) foo

JOIN

autofehlerserie M ON foo.imdb_id = M.imdb_id AND foo.language = M.language and M.marker <> 'D'

ORDER BY

foo.FirstUserDate DESC, M.imdb_id, M.aufloesung, cast(M.season as int), cast(M.episode as int)

回答:

我想你可能真的想:

select m.* 

from autofehlerserie m

where not exists (select 1

from autofehlerserie m2

where m2.imdb_id = m.imdb_id AND m2.language = m.language and

m2.marker = 'D'

);

这将返回表中的所有行,其中有没有其他行具有相同的imdb_idlanguage其是'D'

以上是 SQL SELECT项目,而不字符 的全部内容, 来源链接: utcz.com/qa/265927.html

回到顶部