Tengo una consulta que usa una WHERE
cláusula, y resulta que uso exactamente la misma WHERE
cláusula en muchas consultas en esta tabla (et al).
La consulta es:
SELECT
DATENAME(DW, [AtDateTime]) AS [Day of Week]
,COUNT(*) AS [Number of Searches]
,CAST(CAST(COUNT(*) AS DECIMAL(10, 2))
/ COUNT(DISTINCT CONVERT(DATE, [AtDateTime])) AS DECIMAL(10, 2))
AS [Average Searches per Day]
,SUM(CASE WHEN [NumFound] = 0 THEN 1 ELSE 0 END)
AS [Number of Searches with no Results]
,CAST(CAST(SUM(CASE WHEN [NumFound] = 0 THEN 1 ELSE 0 END)
AS DECIMAL(10, 2)) / COUNT(*) AS DECIMAL(10, 4))
AS [Percent of Searches with no Results]
FROM [DB].[dbo].[SearchHistory]
WHERE
[CustomerNumber] <> '1234' AND [CustomerNumber] <> '5678'
GROUP BY DATENAME(DW, [AtDateTime]), DATEPART(DW, [AtDateTime])
ORDER BY DATEPART(DW, [AtDateTime])
La parte que deseo cambiar es la WHERE
cláusula, para permitirme usar una tabla de manera que si tengo que agregar un número de cliente para ser ignorado, no tenga que actualizar todas mis consultas. (Y hay bastantes consultas que tienen esta misma WHERE
cláusula).