SELECT *FROM ( SELECT TOP (@count1) a.* FROM Article AS a WITH (NOLOCK)LEFT JOIN Article_Type AS at WITH (NOLOCK)ON a.ArticleType=at.ArticleTypeIdWHER ...
SELECT *
FROM (
SELECT TOP (@count1) a.* FROM Article AS a WITH (NOLOCK)
LEFT JOIN Article_Type AS at WITH (NOLOCK)
ON a.ArticleType=at.ArticleTypeId
WHERE a.IsDelete=0 AND a.Status=0
AND at.ArticleTypeId=@articleType1---條件變換
AND a.IssueTime<GETDATE()
ORDER BY a.IssueTime DESC,a.ArticleType ASC
) t
UNION ALL
SELECT *
FROM (
SELECT TOP (@count2) a.* FROM Article AS a WITH (NOLOCK)
LEFT JOIN Article_Type AS at WITH (NOLOCK)
ON a.ArticleType=at.ArticleTypeId
WHERE a.IsDelete=0 AND a.Status=0
AND at.ArticleTypeId=@articleType2---條件變換
AND a.IssueTime<GETDATE()
ORDER BY a.IssueTime DESC,a.ArticleType ASC
) t
UNION ALL
SELECT *
FROM (
SELECT TOP (@count3) a.* FROM Article AS a WITH (NOLOCK)
LEFT JOIN Article_Type AS at WITH (NOLOCK)
ON a.ArticleType=at.ArticleTypeId
WHERE a.IsDelete=0 AND a.Status=0
AND at.ArticleTypeId=@articleType3 ---條件變換
AND a.IssueTime<GETDATE()
ORDER BY a.IssueTime DESC,a.ArticleType ASC
) t