0373 Закарьяев КР Задание-2

0

Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

with
amounts(TagId, Month, Year, Amount)
as
(
select
  t.TagId as TagId,
  month(p.CreationDate) as Month,
  year(p.CreationDate) as Year,
  count(*) as Amount
from
Posts p
inner join PostTags t on p.Id = t.PostId
group by t.TagId, month(p.CreationDate), year(p.CreationDate)
),
nummed(TagId, Month, Year, Amount, n)
as
(
select
  TagId,
  Month,
  Year,
  Amount,
  row_number() over(PARTITION BY TagId ORDER BY Amount DESC) as n
from
  amounts
)

select TagId, Month, Year, Amount 
from nummed
where
  n = 1
order by TagId

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results