Sorry, I meant to REMOVE the GROUP BY.
Start with making sure the result of the DATEDIFFs and the CASE expressions are coming out correctly.
Once you've verified they're producing the correct results, use that query in either a CTE or subquery and use CASE or IIF inside COUNT for each age group.
EDIT: I just realized after looking again that you're SUMming Amt, not counting the number of transactions... I added that.
DECLARE @AsOfDate date = '2022-06-30';
WITH TransactionAges AS
(
SELECT customer_id
, trans_date
, trans_amount
, Amt
, billing_period
, DATEDIFF(day, trans_date, @AsOfDate) AS Age
FROM YourTable
WHERE trans_date < @AsOfDate
)
SELECT customer_id
, trans_date
, trans_amount
, billing_period
, COUNT(IIF( Age < 30, 1, NULL)) AS [Count 0-29]
, COUNT(IIF(Age >= 30 AND Age < 60, 1, NULL)) AS [Count 30-59]
, COUNT(IIF(Age >= 60 AND Age < 90, 1, NULL)) AS [Count 60-89]
, COUNT(IIF(Age >= 90 , 1, NULL)) AS [Count 90+]
, SUM(IIF( Age < 30, Amt, 0)) AS [Amt 0-29]
, SUM(IIF(Age >= 30 AND Age < 60, Amt, 0)) AS [Amt 30-59]
, SUM(IIF(Age >= 60 AND Age < 90, Amt, 0)) AS [Amt 60-89]
, SUM(IIF(Age >= 90 , Amt, 0)) AS [Amt 90+]
FROM TransactionAges
GROUP BY customer_id
, trans_date
, trans_amount
, billing_period
;