Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 optimising the query -

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2010-12-27 : 01:23:35
PLease help me to optimize the below mentioned query.

SELECT COUNT([DeliveredFileName]) AS [OutputFilesCreated] FROM
(SELECT
a.[DeliveredFileName]
FROM
table1 a
INNER JOIN
table2 b
ON
a.[ClearinghouseClaimIdentifier] = b.[ClearinghouseClaimIdentifier]
WHERE
b.[ProcessingClearinghouseIdentifier] IN ('OK')
AND
DATEADD(DAY,DATEDIFF(DAY,0,a.[DateHourStamp]),0) = '2010-12-06'
GROUP BY
a.[DeliveredFileName]
) Temp


thanks
subha

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-12-27 : 02:57:13
[code]SELECT COUNT([DeliveredFileName]) AS [OutputFilesCreated]
FROM (
SELECT a.[DeliveredFileName]
FROM table1 as a
INNER JOIN table2 as b ON b.[ClearinghouseClaimIdentifier] = a.[ClearinghouseClaimIdentifier]
AND b.[ProcessingClearinghouseIdentifier] = 'OK'
WHERE a.[DateHourStamp] >= '20101206'
AND a.[DateHourStamp] < '20101207'
GROUP BY a.[DeliveredFileName]
) as Temp[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-27 : 03:00:57
quote:
Originally posted by subhaoviya

PLease help me to optimize the below mentioned query.

SELECT COUNT([DeliveredFileName]) AS [OutputFilesCreated] FROM
(SELECT
a.[DeliveredFileName]
FROM
table1 a
INNER JOIN
table2 b
ON
a.[ClearinghouseClaimIdentifier] = b.[ClearinghouseClaimIdentifier]
WHERE
b.[ProcessingClearinghouseIdentifier] = 'OK'
AND
(a.[DateHourStamp] >= '20101206' and a.[DateHourStamp] < '20101207')
GROUP BY
a.[DeliveredFileName]
) Temp


thanks
subha




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-27 : 03:01:48



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -