? ? 求差集 ? select distinct abc from A where exists (SELECT valueFROM A uc WHERE? id='1') ?? ? ? except ?? ?select distinct abc from A where CityId in (SELECT value FROM B uc WHERE? id='1')
?
?
?
--按分类重新构建表结构 ?with A1 as ( ?? ?select Aid,A1name from A where type='A1' ), A2 as ( ?? ?select A2id,A2name from A where type='A2' ), A3 as ( ?? ?select A3id,A3name from A where type='A3' ), A4 as ( select A4id,A4name from A where type='A4' ) select A1.A1id,A2.A2name,A3.A3id,A4.A4name
into A1A2A3A4 from A1 A ?left join A2 B on? condition1 left join A3 C on? condition2 left join A4 D on condition3 --创建非聚合索引 create NONCLUSTERED INDEX indexName on A1A2A3A4(A1name,A2name,A3name);
?
?
exists使用
?
?
?
子查询方法
例:select top 3 * from (select top 5 id,vNo from vProduction where 1=1 order by id desc) as tab 将查询另取为表名
?
?
REPLACE(STR,'-','') 替换字符串中的一些字符
CONVERT(VARCHAR,GETDATE(),112) 按112格式yymmdd将日期转为字符串
cast(123 as nvarchar) 将数字转换为字符串
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|