В приведенном ниже запросе выдается ошибка, как показано ниже:
Подзапрос возвращает более 1 значения. Это недопустимо, если подзапрос следует =,! =, <, <=,>,> =.
ALTER PROCEDURE [dbo].[usp_s_AlphaBotAssociatedUserList] @AlphaBotMasterId INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT u.UserName
,u.Id AS UserId
,(
SELECT COUNT(*)
FROM dbo.AlphaBotMasterSetting AS abms
WHERE abms.AlphaBotMasterId = @AlphaBotMasterId
AND ISNULL(abms.IsActive, 0) = 1
) AS TotalAlphaBotMasterMarkets
,(
SELECT COUNT(*)
FROM dbo.UserSessionDetail AS usd
WHERE ISNULL(usd.IsSessionClosed, 0) = 0
AND usd.UserSessionId IN (
SELECT Id
FROM dbo.UserSessions AS us
WHERE us.AlphaBotMasterId = @AlphaBotMasterId
AND ISNULL(us.IsActive, 0) = 1
)
) AS ConfiguredMarkets
,(
SELECT ISNULL(us.IsActive, 0)
FROM dbo.UserSessions AS us
WHERE us.AlphaBotMasterId = @AlphaBotMasterId
) IsSessionRunning
FROM dbo.AlphaBotClient AS abc
INNER JOIN dbo.AlphaBotClientPayment AS abcp ON abcp.AlphaBotClientId = abc.Id
INNER JOIN dbo.AbpUsers AS u ON abc.CreatorUserId = u.Id
WHERE abc.AlphaBotMasterId = @AlphaBotMasterId
AND abcp.Type = 'Confirmed'
END;