This is my query. I know it’s not correct in particular the count syntax.
your text
select distinct product as Type,
your text
count (distinct c.id) as [Total Count],
your text
count (distinct c.id = c.qDate >= ‘2023-06-06 00:00:00.0000000’) as [Count < One Year],
your text
count (distinct c.id = c.qDate >= ‘2022-06-06 00:00:00.0000000’) as [Count < Two Year]
your text
FROM [table1] t1
your text
join [table2] t2 on t1.ID = t2.ID
your text
join [table3] t3 on t2.mb = t3.mb
your text
where status in (‘P’, Null)
your text
group by Product, c.qDate
your text
order by Product
Sample of what I want my query to return
Type TotalCount Count < 1 Yr Count < 2 Yrs
Van 10000 3000 7000
Car 50000 30000 70000
Truck 5000 200 500
John O is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.