久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

TSQL - 尋找代碼澄清

TSQL - Looking for code clarification(TSQL - 尋找代碼澄清)
本文介紹了TSQL - 尋找代碼澄清的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

這是我使用的代碼,結果貼在下面:

This is the code I used and the result is posted below:

SELECT * 
FROM
    (SELECT 
         P.ProductID, PC.Name, ISNULL (P.Color, 'uncolored') AS color
     FROM 
         SalesLT.ProductCategory AS PC
     JOIN 
         SalesLT.Product AS P ON PC.ProductCategoryID = P.ProductCategoryID
) AS PPC
PIVOT 
    (COUNT (ProductID) FOR Color IN ([Red],[Blue],[Silver],[Black],[Yellow],[Grey],[Multi],[Uncolored])) AS pvt
ORDER BY 
    Name;

我沒有要求查詢提供我的名字,有人能解釋一下這個名字"是如何出現在結果中的嗎?如果我希望 ProductID 出現而不是名稱,我該如何修改代碼?

I didn't request the query to provide me the name, could someone explain me how this 'name' thing popped up in the result? How can I modify the code if I want ProductID to appear instead of name?

非常感謝任何幫助或反饋.

Any help or feedback would be greatly appreciated.

推薦答案

ProductID 不會顯示,因為您在透視表時將其用作聚合列.只會顯示每種顏色的產品 ID 計數.為了查看 ProductID 刪除查詢的數據透視部分.Name 顯示在您的最終結果中,因為它存在于您的內部查詢中.

ProductID won't show because you have used it as an aggregation column while pivoting the table. Only the counts of product Id for each colour will be shown. For seeing ProductID remove the pivot part of query. Name shows up in your final result because it is there in your inner query.

旋轉表格將行更改為列.在您的情況下,顏色 Red、Blue、Silver、Black、Yellow、Grey、Multi、Uncolored(如在 pivot 子句中給出)的行值更改為列.在這些列的每一列下,顯示了該顏色的表中的 ProductID 計數以及名稱"列中的名稱.因此在查詢中沒有任何地方顯示單個 productId.內部查詢的 ProductID 列僅用于計算計數,不顯示在最終結果中.

Pivoting the table changes rows to columns. In your case the row values for colours Red,Blue,Silver,Black,Yellow,Grey,Multi,Uncolored ( as given inside pivot clause) are changed to columns. Under each of these columns, the counts of ProductIDs present in the table for that colour and the name in 'Name' column are shown. So nowhere in the query individual productIds are shown. The ProductID column the inner query is only used for calculating counts and not shown in final result.

這篇關于TSQL - 尋找代碼澄清的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Modify Existing decimal places info(修改現有小數位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 午夜影院在线播放 | 韩日一区二区三区 | 欧美 日本 国产 | 日韩中文电影 | 日本在线网址 | 亚洲免费精品 | 久久久久久国产精品 | 久久专区 | 麻豆91精品91久久久 | 亚洲一区二区三区在线视频 | 国产成人精品一区 | 日韩一区二区av | 日本中出视频 | 91小视频在线 | 一区二区三区在线播放 | 狠狠狠 | 精品欧美一区二区在线观看视频 | 精品免费国产视频 | 嫩草黄色影院 | 日韩久草 | 国产电影一区二区 | 亚州av | 欧美一区二区三区免费电影 | 中国一级特黄真人毛片 | 午夜视频免费网站 | 国内精品久久久久久 | 亚洲国产精品久久久久秋霞不卡 | 污书屋 | 欧美三级视频在线观看 | 色黄视频在线 | 羞羞免费网站 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 一区二区三区四区视频 | 特级生活片 | 天天看夜夜 | 欧美日韩国产精品激情在线播放 | 在线视频中文字幕 | 91亚洲精华国产 | 偷拍亚洲色图 | 国产精品一区二区欧美黑人喷潮水 | 激情五月婷婷综合 |