Last active
August 29, 2015 14:25
-
-
Save danieleli/1a62855c95d9fcd2946a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER FUNCTION [dbo].[Creative_Grid] ( | |
@start DATETIME, | |
@end DATETIME, | |
@clientIds VARCHAR(MAX), | |
@seId VARCHAR(MAX) = null, | |
@campaignId VARCHAR(MAX) = null, | |
@adCategoryId VARCHAR(MAX) = null | |
) | |
RETURNS TABLE AS RETURN | |
( | |
SELECT | |
creative_base.*, | |
fact.*, | |
onsite.* | |
FROM | |
creative_base | |
JOIN Creative_Fact ( @start, @end, @clientIds, @seId, @campaignId, @adCategoryId ) AS fact | |
ON creative_base.creativeid = fact.FactCreativeId | |
LEFT OUTER JOIN Creative_Fact_Onsite ( @start, @end, @clientIds, @seId, @campaignId, @adCategoryId ) AS onsite | |
ON creative_base.creativeid = onsite.OnsiteCreativeid | |
WHERE | |
creative_base.AdStatusID != 3 | |
AND creative_base.AdTypeID = 1 | |
AND creative_base.ClientID in (SELECT * FROM Split(@clientIds, ',')) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment