📜 ⬆️ ⬇️

SQL task

Given:


Table Numbers with a single column ID of type INT .
@ID value
@MaxAmount value

To find:


With one SELECT ', assign the unit @Available to the unit (1) if the number of records in the table does not exceed @MaxAmount and there are no records in the table with a value equal to @ID . Otherwise, do not assign anything to the @Available parameter.

Complication:


Do it all without a CASE operator.
')
PS I solved this problem for myself and it seemed so interesting to me that I decided to share it with you. These are like problems with an asterisk in textbooks on algebra and geometry.

Source: https://habr.com/ru/post/11389/


All Articles