SQL Server 交叉表查询 case建站知识
导读:1建站知识今天下午忙于将access数据库中的交叉表转到SQL server数据库中,在SQL server中,不支持transfrom方法,查找相关资料,找到公司网站建设营销型网站建设。
代码如下所示:
表landundertake结构如下所示:
表appraiser结构如下所示:
access代码:
复制代码 代码如下:
TRANSFORM First(Landundertake.valuerId) AS valuerId之First SELECT Appraiser.quarterId, Landundertake.landCode FROM Landundertake INNER JOIN Appraiser ON (Landundertake .valuerId = Appraiser.valuerID) AND (Landundertake .quarterId = Appraiser.quarterId) GROUP BY Appraiser.quarterId, Landundertake .landCode PIVOT Landundertake .valuerGrade;
SQL server代码:复制代码 代码如下:
select dbo.appraiser.quarterID,dbo.landUndertake.landcode,case dbo.landUndertake.appraiserGrade when 'appraiserID1' then dbo.landundertake.appraiserID else null END as appraiserID,case dbo.landUndert网站seo优化软件ake网站seo优化.appraiserGrade when 'appraiserID2' then dbo.landundertake.apprai网站推广优化seoserID else null END as appraiserID1 from dbo.LandUndertake inner join dbo.Appraiser ON dbo.LandUndertake.quarterID=dbo.appraiser.quarterID and dbo.landundertake.appraiserID=DBO.Appraiser.appraiserID Group by dbo.appraiser.quarterID,dbo.landUndertake.landcode,dbo.landundertake.appraiserGrade,dbo.landundertake.appraiserID
交叉表查询结果如下所示: 相关公司网站建设营销型网站建设。声明: 本文由我的SEOUC技术文章主页发布于:2023-05-21 ,文章SQL Server 交叉表查询 case建站知识主要讲述标签,标题,SQL网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_3721.html