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

執(zhí)行按位求和

Performing a bitwise sum(執(zhí)行按位求和)
本文介紹了執(zhí)行按位求和的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

作為復(fù)雜聚合的一部分,我想知道一些數(shù)據(jù)的按位總和,即如果我有值為 1,1,1,2,2,8 的行,按位 sum 是 11.在這種情況下,這些值都是 2 的精確冪(單個位),因此我可以通過對組進行分組和求和來繞過它(顯然,與實際查詢相比,這個示例有點受折磨)):

As part of a complex aggregate I want to know the bitwise sum of some data, i.e. if I have rows with values 1,1,1,2,2,8 the bitwise sum is 11. In this case the values are all exact powers of two (single bits), so I can hack around it by grouping and summing over the groups (obviously this example is a bit tortured compared to the real query):

select SUM(y.test)
from (
    select x.test
    from ( -- garbage test data
        select 1 as [test]
        union all select 1
        union all select 1
        union all select 2
        union all select 2
        union all select 8) x
group by x.test) y

但是有沒有一種干凈的方法可以在 [T]SQL 中執(zhí)行按位求和?

but is there a clean way to perform a bitwise sum in [T]SQL?

推薦答案

如果您的所有測試值都是單個位,如您的示例 (1, 2, 8) - 只需使用 SUM(DISTINCT col) 在您的查詢中.

If all of your test values are single bits as in your example (1, 2, 8) - simply use SUM(DISTINCT col) in your query.

希望有所幫助.

(參考:http://msdn.microsoft.com/en-us/library/ms187810.aspx)

這篇關(guān)于執(zhí)行按位求和的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
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屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 一区在线视频 | 91精品国产综合久久小仙女图片 | 黄色一级大片在线免费看产 | 一区二区在线不卡 | 日韩精品一区二区三区在线播放 | 欧美a级网站| 天天拍天天操 | 国产精品亚洲精品日韩已方 | 免费一级欧美在线观看视频 | 一区二区三区四区在线视频 | 天堂av中文在线 | 亚洲日韩中文字幕一区 | 欧美一区二区三区在线 | 久久国产电影 | 亚洲精品久久久一区二区三区 | 亚洲欧美在线视频 | 午夜不卡福利视频 | 狠狠涩| 日韩欧美在线免费观看视频 | 日韩精品一区二区三区在线观看 | 亚洲精品国产一区 | 日韩亚洲欧美综合 | 国产精品久久久久久238 | 久久精品这里精品 | 国产精品久久一区二区三区 | 免费视频一区二区三区在线观看 | 91精品国产综合久久久久久丝袜 | 欧美精品日韩 | 一区二区不卡 | 免费性视频 | 91精品午夜窝窝看片 | 岛国午夜| 亚洲小视频在线观看 | av资源中文在线天堂 | av黄色片 | 天天干天天插天天 | 日本在线视频一区二区 | 欧美午夜精品久久久久免费视 | 日韩欧美一区二区三区免费观看 | 亚洲视频在线观看 | 国产成人免费观看 |