SQL记录

SQL Server

去掉首尾空格

代码

UPDATE 表table
SET 属性a = RTRIM(LTRIM(属性a))

示例

UPDATE BU8MC_MatInfo_Loss
SET MatId = RTRIM(LTRIM(MatId))

查找另一个表没有的记录

代码

SELECT * FROM 表a
WHERE Kind = '实际损耗类型'
    AND MatId NOT IN (
	    SELECT MatId FROM b);

查找重复属性的记录

SELECT MatId, COUNT(*) AS Count
FROM BU8MC_Storage
WHERE Factory = ''
GROUP BY MatId
HAVING COUNT(*) > 1

求和

SELECT SUM(MatOutputNum) AS TotalOutputNum  
FROM BU8MC_OutPutAll
WHERE MatId = '' and Factory = '';
posted @ 2023-08-23 15:49  敲代码的小胖虎  阅读(11)  评论(0编辑  收藏  举报