久久久久久久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)
主站蜘蛛池模板: 日本精品一区二区 | 欧美日韩成人影院 | 女人一区 | 国产精品久久久久久久久免费樱桃 | 国产不卡视频在线 | 久久一 | 久久精品影视 | 精品福利在线 | 久久一日本道色综合久久 | 亚洲444kkkk在线观看最新 | 久99久视频| 黄色大片网 | 亚洲国产精品一区二区久久 | 亚洲综合大片69999 | 成人国产午夜在线观看 | 日本一区二区高清不卡 | 精品国产一区二区三区久久久四川 | 日韩高清中文字幕 | 国产成人一区二 | 亚洲成人99| 国产高清精品一区二区三区 | 久久精品网| 天天影视网天天综合色在线播放 | 国产乱一区二区三区视频 | 国产精品免费一区二区三区四区 | 亚洲444kkkk在线观看最新 | 色嗨嗨 | 国产精品视频久久久久 | 精品欧美一区二区三区久久久 | 99精品国产一区二区青青牛奶 | 亚洲日本成人 | 国产精品国产精品国产专区不片 | 自拍视频精品 | 久久久精品天堂 | 色久影院| 最新91在线 | 荷兰欧美一级毛片 | 日韩亚洲一区二区 | 久久久久久成人 | 九九热在线观看视频 | 亚洲毛片在线 |