Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

performance

$
0
0

SELECT        Hits.orgId, OrgTypes.Title, isnull(SUM(Hits.Hits),0) AS TotalHits,
                              (SELECT        SUM(Hits) AS Expr1
                               FROM            orgHits
                               WHERE        (ProductType = 1) AND (orgId = Hits.orgId)) AS Hitstype1,
                             (SELECT        isnull(SUM(Hits),0) AS Expr1
                               FROM            orgHits AS orgHits_2
                               WHERE        (ProductType = 2) AND (orgId = Hits.orgId)) AS Hitstype2,
                             (SELECT        isnull(SUM(Hits),0) AS Expr1
                               FROM            orgHits AS orgHits_1
                               WHERE        (ProductType = 3) AND (orgId = Hits.orgId)) AS Hitstype3, Org.Name
                               ,Hits.Year
                               ,hits.Month
FROM            orgHits AS Hits INNER JOIN
                         orgs AS Org ON Org.Id = Hits.orgId INNER JOIN
                         orgtypes AS OrgTypes ON Org.OrganizationType = OrgTypes.Type

GROUP BY Hits.orgId, Org.Name, OrgTypes.Title,Hits.Year
                               ,hits.Month

how can i make this query to run faster??



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>