SQL Server 交叉表查询 case
时间:2024-01-18 19:05:48
代码如下所示:
表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.landUndertake.appraiserGrade when 'appraiserID2' then dbo.landundertake.appraiserID 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
交叉表查询结果如下所示:
标签:交叉表查询
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
asp代码WinHttp.WinHttpRequest.5.1使用例子
2010-03-11 21:28:00
vscode使用nuget包管理工具
2023-10-30 13:37:55
![](https://img.aspxhome.com/file/2023/7/114687_0s.png)
Python中的文件输入输出问题
2022-06-12 05:22:24
![](https://img.aspxhome.com/file/2023/6/112046_0s.png)
python K近邻算法的kd树实现
2022-01-09 19:05:43
css去掉checkbox边框的方法
2011-06-06 10:32:00
Python数字比较与类结构
2023-07-29 13:33:51
![](https://img.aspxhome.com/file/2023/3/125053_0s.png)
Python程序实现向MySQL存放图片
2022-12-02 13:34:38
![](https://img.aspxhome.com/file/2023/0/67840_0s.png)
JavaScript实现大文件上传的示例代码
2024-05-28 15:40:23
vue中实现拖动调整左右两侧div的宽度的示例代码
2024-04-27 16:02:36
![](https://img.aspxhome.com/file/2023/3/133043_0s.gif)
js Canvas实现的日历时钟案例分享
2024-04-22 13:08:26
![](https://img.aspxhome.com/file/2023/6/135766_0s.png)
Python批量添加图片水印的实现
2021-11-04 17:53:12
![](https://img.aspxhome.com/file/2023/9/131099_0s.png)
Python OpenCV对图像像素进行操作
2021-02-25 13:02:20
![](https://img.aspxhome.com/file/2023/3/135153_0s.jpg)
SqlServer参数化查询之where in和like实现详解
2012-05-22 18:10:50
Python基础详解之列表复制
2022-09-24 02:39:10
![](https://img.aspxhome.com/file/2023/9/103749_0s.png)
Python使用Asyncio实现检查网站状态
2023-01-23 18:56:39
Python的Flask站点中集成xhEditor文本编辑器的教程
2023-04-05 00:41:06
![](https://img.aspxhome.com/file/2023/6/72236_0s.jpg)
opencv-python 读取图像并转换颜色空间实例
2022-04-08 04:02:55
教你用python将数据写入Excel文件中
2021-12-29 03:28:38
![](https://img.aspxhome.com/file/2023/8/97638_0s.png)
获取url中用&隔开的参数实例(分享)
2024-05-28 15:40:46
无法在发生错误时创建会话,请检查 PHP 或网站服务器日志,并正确配置 PHP 安装最快的解决办法
2023-09-03 19:49:50