V
V
Vitaly Kostyuk2018-04-25 22:00:19
SQL
Vitaly Kostyuk, 2018-04-25 22:00:19

Do you need something like an array here?

Get a list of athletes who are involved in several sports, specifying all types.
I did this, but the task states that there can be either 1 or 2, etc.

ALTER PROCEDURE [dbo].[Query4]
  @видСпорту1 nvarchar(50),
  @видСпорту2 nvarchar(50)
AS
BEGIN
  
  SET NOCOUNT ON;

   select    Спортсмен.[Ім'я],Спортсмен.Прізвище  

From [Спортсмен_Вид спорту]
join Спортсмен on Спортсмен.id = [Спортсмен_Вид спорту].[id Спортсмена]
join [Вид спорту] on [Вид спорту].id = [Спортсмен_Вид спорту].[id Вид спорту]
join [Розряд спортсмена] on [Розряд спортсмена].id = [Спортсмен_Вид спорту].[id Розряд Спортсмена]
join [Спортивний клуб] on [Спортивний клуб].id = [Спортсмен_Вид спорту].[id Спортивного клубу]

where [Вид спорту] in (@видСпорту1,@видСпорту2)
GROUP BY Спортсмен.[Ім'я],Спортсмен.Прізвище

having count([Вид спорту])>1
END

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sanyashufter, 2020-07-31
@sanyashufter

Thank you very much, I used your work when I compiled the list of football champions. now I want to start developing a mobile application for the bookmaker Leon using this example just for myself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question