I have two simple columns: datetime PayDate and int Amount
I tried to write a query that separate count of Amount per day but it doesnt work.
SELECT YEAR(PayDate) + '/' + MONTH(PayDate) + '/' + DAY(PayDate) as a,
COUNT(Amount) as b
FROM TABLE1
GROUP BY a,b
Thank you for help.
Why are you bothering with all this messy string concatenation? Format on the client if you want a specific output. Use base types instead of strings where possible.
If you have a justified complex expression, the easiest way to avoid repeating it is to use a subquery or CTE:
(I have no idea why you are grouping by both a and b in your question.)