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

計數和組合行

Counting and combining rows(計數和組合行)
本文介紹了計數和組合行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個表格,通過向每行的國家/地區代碼"列添加國家/地區代碼來記錄我的 Web 應用程序中的用戶位置.每行代表對特定區域的訪問.

I have a table that is recording user locations from my web application by adding a country code to the 'countrycode' column of each row. Each row is representing a visit to a particular area.

所以我有一些數據,比如

So I have some data like

COL1    COL2    COL3    countrycode
asd     asd     asd        NZ
asd     asd     asd        NZ
asd     asd     asd        NZ
asd     asd     asd        US
asd     asd     asd        US

我想要做的是查詢這個表并在下面顯示類似這樣的內容

What I want to do is to query this table and show me something like this below

Country    Count
   NZ        3
   US        2

但我需要它能夠為出現的更多國家/地區代碼添加一行.我無法理解如何做到這一點,我知道我需要以某種方式使用 COUNT() 函數......

But I need it to be able to add a row for any more country codes that have come up. I cant get my head around a way to do this, I know I need to use the COUNT() function somehow...

推薦答案

要獲得示例輸出,您可以使用 GROUP BYCOUNT()

To get your example output, you can use GROUP BY and COUNT()

SELECT Country, COUNT(*)
FROM myTable
GROUP BY Country 

COUNT(*) 將計算每一行,GROUP BY Country 將按國家/地區拆分結果.結果將是基于表中數據的動態結果,因此如果您在表中添加具有不同國家/地區的更多記錄,則無需更改查詢.

COUNT(*) will count ever row and GROUP BY Country will split the results out by Country. The results will be dynamic based on the data in the table so you don't need to change your query if you add more records in the table with different countries.

請參閱在線圖書分組依據

這篇關于計數和組合行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 亚洲自拍偷拍免费视频 | 国产精品久久久久久久免费观看 | 国产精品久久久久久久久久三级 | 久久久精品一区二区三区 | 伊人色综合久久久天天蜜桃 | 久久久精品高清 | 国产一区二区影院 | 91高清在线观看 | 国产精品色 | 免费成人高清在线视频 | 国产一区二区自拍 | 欧美一级视频 | 成年免费大片黄在线观看岛国 | 中文天堂在线观看 | 中文一区二区 | 成人精品视频 | 精品久久久精品 | 亚洲乱码一区二区三区在线观看 | 欧美成人aaa级毛片在线视频 | 先锋资源吧 | 亚洲国产中文字幕 | 亚洲一区免费 | 国产日韩视频在线 | 成人性生交大片 | 日韩一区在线视频 | 琪琪午夜伦伦电影福利片 | 中文字幕av网站 | 免费99精品国产自在在线 | 欧美日韩国产综合在线 | 精品成人在线视频 | 91 久久| 亚洲精品国产一区 | 99综合 | 久草在线 | 婷婷色国产偷v国产偷v小说 | 欧产日产国产精品v | 亚洲高清在线 | 精品一区二区久久久久久久网站 | 亚洲日本免费 | www.久草.com | 女生羞羞视频 |