like the title said, here is my code:
SELECT
material,
SUM([Amount]) AS [Amount],
RIGHT(CONVERT(varchar(50), [date_in], 106), 8)
FROM
[rec_stats]
GROUP BY
material,
RIGHT(CONVERT(varchar(50), [date_in], 106), 8)
ORDER BY
material,date_in
the code wont run because of the date_in, is there anyway to get around this?
Key Differences between GROUP BY and ORDER BY The Group By clause is used to group data based on the same value in a specific column. The ORDER BY clause, on the other hand, sorts the result and shows it in ascending or descending order. It is mandatory to use the aggregate function to use the Group By.
The direct answer is that you can't. You must select either an aggregate or something that you are grouping by.
Yes, you can order by a field(s)even if it is not your in your select statement but exists in your table. For a group by clause though you'd need it to be in your select statement. is it possible to give an SELECT statement ...
No, the order doesn't matter for the GROUP BY clause.
Apply another aggregate, so how about;
order by min([date_in])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With