常用SQL语句

1. 查询不包含指定内容的数据

 select * from [ZY].[dbo].[l_DiseaseSymptoms] where  Disease_Name='脾肺积热' and Disease_Type NOT LIKE '%八纲辨证%'

2. 读取名字重复两次以上的数据

select Disease_Name, count(Disease_Name) from l_DiseaseSymptoms  group by Disease_Name having count(Disease_Name)>1

3. 获取栏位最长的数据(看看最长的数据有多长)

SELECT TOP 1 Item_NiShiSpeak, LEN(Item_NiShiSpeak) AS length
FROM s_BookItem
ORDER BY length DESC;

4. 统计不同条件的总数(按多个条件统计总数,case 使用)

select Device_ID,
SUM(case when Drug_Unit='' then Box_Num else 0 end) as zhi,
SUM(case when Drug_Unit='' then Box_Num else 0 end) as he from s_DrugInfo_DrugBox group by Device_ID;
posted @   apple-hu  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示