我有以下内容:
USE xxx
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[branches](
[branchNumber] [int] NULL,
[isSub] [char](1) NULL,
[masterBranch] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
insert into branches
values ( 115, 'Y', 900 )
insert into branches
values ( 123, 'Y', 900 )
insert into branches
values ( 150, 'Y', 900 )
insert into branches
values ( 900, 'N', null )
insert into branches
values ( 901, 'N', null )
go
我需要检查 a) 115 a isSub = Y 吗?如果是,那么我完成返回 115。 b) 900 是 IsSub = Y 吗?如果不是,我需要返回:115、123、150、900。c) 是 901 a isSub = Y?如果没有,我需要返回 901。
自从我查看 rank() 函数以来已经有一段时间了,所以我现在有点卡住了。任何帮助将不胜感激。谢谢