Here,
there are two time , group by applied by using sub query in single query
Syntax of sql query:
following query showing with two time group by and data difference
select publisherWeb as Publisher,count(Adcount) as Adcount from
(
select publisherWeb,count(Adinfo) as Adcount from tblICA2008 where (DATEDIFF(Month, CAST(Year AS varchar) + '-' + CAST(Month AS varchar) + '-' + CAST(Day AS varchar), GETDATE()) <6) group by publisherWeb,Adinfo
) t
group by publisherWeb order by Adcount
sub query usually hit the perfroamce as there will multiple select stattements. The same can be altered using joins which can improve the performance by 70%
ReplyDelete