枢轴表返回零
您能帮我用枢轴桌吗?由于某种原因,它返回所有零! 我的代码是
SELECT VendorID, ['Y'] , ['N']
FROM
(SELECT
VendorSiteID,
Local,
VendorID
FROM [DB]) p
PIVOT
(
COUNT (VendorSiteID)
FOR Local IN
( ['Y'], ['N'] )
) AS pvt
order by [VendorID]
我的示例数据是
vendorid | vendorsiteid | local |
---|---|---|
123 | abc | y |
456 | def | n |
789 | ghi n ghi | n |
预期结果:
vendorid | y | n |
---|---|---|
123 | 1 | |
456 | 1 | |
789 | 1 |
非常感谢您!
could you please help me with pivot table. For some reason it returns all zeros!
my code is
SELECT VendorID, ['Y'] , ['N']
FROM
(SELECT
VendorSiteID,
Local,
VendorID
FROM [DB]) p
PIVOT
(
COUNT (VendorSiteID)
FOR Local IN
( ['Y'], ['N'] )
) AS pvt
order by [VendorID]
my sample data is
VendorID | VendorSiteID | Local |
---|---|---|
123 | ABC | Y |
456 | DEF | N |
789 | GHI | N |
Expected result:
VendorID | Y | N |
---|---|---|
123 | 1 | |
456 | 1 | |
789 | 1 |
Thank you very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不得不删除报价,一切都在起作用!!
I had to remove quotes and everything is working!!