V
V
vlad_2810932017-09-12 00:12:06
SQL
vlad_281093, 2017-09-12 00:12:06

Why does mssql throw an error?

sqlfiddle.com/#!6/14e507/16
Wording:
"We need to remove unnecessary entries and leave only the first clients"
The passport number must be unique.
Error: An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Actually, I tried it in SQLLite, and everything worked fine:
sqlfiddle.com/#!7/68e68/2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2017-09-12
@k1lex

DELETE e
FROM #employees e
INNER JOIN (
  SELECT id
    ,RANK() OVER (PARTITION BY pass_num ORDER BY ID) RNK
  FROM #employees
  ) X ON X.id = e.id
WHERE x.RNK > 1

R
Rsa97, 2017-09-12
@Rsa97

I am practically not familiar with MSSQL, but the error is quite understandable.
HAVING expects an expression whose result is TRUE or FALSE. You are trying to slip an integer value MIN (id).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question