Inner case to main where select :-/
From answers :
ALTER PROCEDURE [dbo].[HardQ3]
(@ID_User nvarchar(15), @ID_ListGroupParIzm Integer,@CIzmer Integer, @CPoint Integer, @UserExt bit)
AS
SELECT * FROM
(
SELECT
C.ID_ListParIzm,
C.Hint,
CAST(CASE WHEN T2.ID_Param IS NULL AND T2.UserExt=@UserExt THEN 1 ELSE 0 END as bit) AS Visi ,
T2.UserExt AS UserExt
FROM
CfgListParIzm C
LEFT JOIN
( SELECT
T.ID_Param,
T.UserExt as UserExt
FROM
TbUserParam T
WHERE
T.ID_User = @ID_User
AND T.ID_Izmerit = @CIzmer
AND T.ID_Point = @CPoint
) T2 On T2.ID_Param = C.ID_ListParIzm
WHERE
C.ID_ListGroupParIzm = @ID_ListGroupParIzm AND
C.VisibleOnTab=1
--ORDER BY Num
) d
WHERE (UserExt IS NOT NULL)
T2.UserExt IS NOT NULL wont works because Where is working only after select , so I need to use it in real time on selecting for开发者_开发问答 T2 there.
How to use this case for (T2.UserExt (with inner case)) for each node in main select
I really hope that question is understatable :)
PROCEDURE [dbo].[HardQ3]
(@ID_User nvarchar(15), @ID_ListGroupParIzm Integer,@CIzmer Integer, @CPoint Integer, @UserExt bit)
AS
Select * from (
SELECT
C.ID_ListParIzm,
C.Hint,
CAST(CASE WHEN T2.ID_Param IS NULL AND T2.UserExt=@UserExt THEN 1 ELSE 0 END as bit) AS Visi
FROM
CfgListParIzm C
LEFT JOIN
( SELECT
T.ID_Param,
T.UserExt as UserExt
FROM
TbUserParam T
WHERE
T.ID_User = @ID_User
AND T.ID_Izmerit = @CIzmer
AND T.ID_Point = @CPoint
) T2 On T2.ID_Param = C.ID_ListParIzm
WHERE
C.ID_ListGroupParIzm = @ID_ListGroupParIzm AND
C.VisibleOnTab=1
ORDER BY Num
)d where UserExt IS NOT NULL
精彩评论