摘要: select s.*from ( select row_number() over (partition by [分组字段] order by [排序字段] desc) as order_num,v.* from [表名] v) swhere s.order_num = 1 阅读全文
posted @ 2024-07-15 15:22 f_mao 阅读(139) 评论(0) 推荐(0)
摘要: 1、sqlserver默认不区分大小写: 2、可以手动区分大小写: AND tcn.centerpress_number ='2h(aa01/aa02)' --不区分大小写查询 AND tcn.centerpress_number COLLATE Chinese_PRC_CS_AI_WS='2h(a 阅读全文
posted @ 2024-03-06 14:14 f_mao 阅读(2088) 评论(0) 推荐(0)
摘要: 原始数据和目标数据 实现SQL语句(最大) select shop, month, greatest(dz,fz,sp) as max from tablename; 实现SQL语句(最小) select shop, month, least (dz,fz,sp) as min from table 阅读全文
posted @ 2023-12-28 16:07 f_mao 阅读(1132) 评论(0) 推荐(0)
摘要: tempdb过大处理 1. tempdb 文件过大,可以通过重新启动SQL Server 系统,tempdb数据文件及Log会释放空间到初始大小(比如8M). 2. tempdb 在系统默认的C盘,自动扩展过大可能导致系统盘C盘空间问题,需要迁移到数据盘 。 Use master Alter dat 阅读全文
posted @ 2023-12-07 09:26 f_mao 阅读(936) 评论(0) 推荐(0)
摘要: 开门见山:Oracle client和 Instant client都是属于Oracle客户端,Instant client被称为即时客户端,其相比于前者更为易用轻便、体积更小且拥有作为Oracle客户端的基本功能;而Oracle Client体积大、功能全安装和配置均较为复杂,一般使用Instan 阅读全文
posted @ 2023-11-10 15:36 f_mao 阅读(1593) 评论(0) 推荐(0)
摘要: Create proc [dbo].[P_BackupsCompanyData] (@tablename varchar(256),@where varchar(256)) as begin set nocount on declare @sqlstr varchar(max) declare @s 阅读全文
posted @ 2023-11-10 14:37 f_mao 阅读(81) 评论(0) 推荐(0)
摘要: SELECT 字段1, [列名] = stuff(( SELECT ',' + [字段2] FROM aa t WHERE t.字段1 = aa.字段1 FOR xml path('')) , 1 , 1 , '') FROM aaGROUP BY 字段1 阅读全文
posted @ 2023-10-25 10:36 f_mao 阅读(383) 评论(0) 推荐(0)