-1
如何編寫SQL語句來比較昨天的當前日期和日期。表格具有相同的列。我需要檢查選擇的兩個日期列中哪些數據不同,並顯示兩個表之間的變化。在sql中比較兩個相同的表數據Date
這裏是存儲過程,我開始
CREATE PROCEDURE [dbo].[usp_CompareNetworksandRatings]
@media_month_id smallint,
@rating_category_id tinyint,
@rate_date datetime
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
nn.nielsen_network_id,
nn.code,
nn.name
FROM
daily_ratings dr (NOLOCK)
JOIN media_months mm (NOLOCK) ON mm.id=dr.media_month_id
AND [email protected]_month_id
JOIN uvw_nielsen_network_universes nn (NOLOCK) ON nn.nielsen_network_id=dr.nielsen_network_id
AND nn.start_date<=mm.start_date AND (nn.end_date>=mm.start_date OR nn.end_date IS NULL)
WHERE
[email protected]_category_id
AND [email protected]_month_id
AND [email protected]_date
ORDER BY
nn.code