惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
T
Threatpost
P
Palo Alto Networks Blog
NISL@THU
NISL@THU
O
OpenAI News
Project Zero
Project Zero
G
GRAHAM CLULEY
P
Privacy International News Feed
A
Arctic Wolf
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
D
Docker
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
W
WeLiveSecurity
P
Proofpoint News Feed
腾讯CDC
Cloudbric
Cloudbric
S
Secure Thoughts
C
Check Point Blog
博客园 - Franky
T
The Exploit Database - CXSecurity.com
T
Troy Hunt's Blog
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
月光博客
月光博客
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
F
Fortinet All Blogs
博客园 - 叶小钗
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
C
Cisco Blogs
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 冷风.net

以OO的思想利用JS來實現五子棋 開放幾個原來寫的js代碼,供大家娛樂一下 使用JS寫的第一個游戲[俄羅斯方塊] 假如現在讓你去說服客戶使用asp.net2.0開發系統,你會怎麼說服呢? 對象化javascript日期控件 - 冷风.net - 博客园 工作排程 防止圖片在WEB頁面上下載 - 冷风.net - 博客园 今天從新整理的大小寫數據轉換 - 冷风.net - 博客园 常用的XPATH說明 XmlHttp在DoNet中的完全应用---前/后台完成分离篇 系统用户权限与角色分析 学习设计模式之Composite 模式 改進Richer的WEB頁面進度條! 学习设计模式之Bridge模式 学习设计模式之生成器(Builder Pattern)模式 再谈Abstract Factory模式来实现数据库操作的类 Factory Method来实现数据库操作的类 不周表結構合併問題 利用線程實現錠時執行的運行模型
今天下午困惑的問題,終於TMD搞出來了
冷风.net · 2005-01-07 · via 博客园 - 冷风.net

今天下午郁悶,遇到了下面這個問題,應為以前對case用得少,所以開始沒有想到這上面來,還從什麼鬼游標等其它方面著首去想,真TMD的花了好久時間,後來看到CASE的用法後,呵呵,就簡單了

表名:TableName
字段名 日期
feild    date
abcde  20005-01-01
abc    20005-01-01
abcd   20005-01-01
abcde  20005-01-01
ab     20005-01-02
abc    20005-01-02
abcd   20005-01-02
abcde  20005-01-02
abcd   20005-01-03
abc    20005-01-03

現在查各日期內的字符串的長度為>=1,>=2,>=3,>=4,>=5的各有多少個
如上結果應為:
1   2   3   4   5  日期
4   4   4   3   2  20005-01-01
4   4   3   2   1  20005-01-02
2   2   2   1   0  20005-01-03

select len(field) as lenfield,date  into #countTable form TableName order by date
select sum(case when lenfield>=1 then 1 else 0) as fid1,
sum(case when lenfield>=2 then 1 else 0) as fid2,
sum(case when lenfield>=3 then 1 then 0) as fid3,
sum(case when lenfield>=4 then 1 then 0) as fid4,
sum(case when lenfield>=5 then 1 then 0) as fid5
into #returnTable
from #countTable
group by date
drop table #countTable
drop table #returnTable