连接优化
1 | --before |
插入时去重 insert
1 | INSERT INTO dbo.Learn_CouponSendJob ( |
查询父表数据并 统计子表中的数量
1 | SELECT |
对版本软件版本管理
当前版本和最新之间的版本是否包含强制更新1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25DECLARE @Need INT
SET @Need = (
SELECT
COUNT (1) AS c
FROM
Learn_AppInfo WITH (nolock)
WHERE
version >=@version
AND Needupdate = 1
AND isdeleted = 0
)
SELECT
TOP 1 a.Version,
a.title,
a.content,
a.systemtype,
a.url,
a.auditstatus,
case when @Need> 0 then 1 else 0 end AS NeedUpdate
FROM
Learn_AppInfo a
WHERE
systemtype = 1
AND isdeleted = 0
ORDER BY version DESC