34,838
社区成员




if object_id('dbo.test') is not null drop table dbo.test
CREATE TABLE [dbo].[test](
col1 [nchar](10) NULL,
col2 [decimal] NULL,
col3 [nchar](10) NULL
) ON [PRIMARY]
insert into test
select 'shana', 123, 'male' union all
select 'kangna', 78, 'female' union all
select 'veney', 678, 'female' union all
select 'bagala', 456, 'male' union all
select 'sen', 235, 'male'
-- 视图
alter view testView as
select col1 from test
select * from testView;
-- CTE 查询
with CTE as (
select col1 from test
)
select * from CTE