I have 3 columns in a table as given below:
|---------------------|------------------|-------------|
| dept | class | item |
|---------------------|------------------|-------------|
| 234 | 34 | 6783 |
|---------------------|------------------|-------------|
| 784 | 78 | 2346 |
|---------------------|------------------|-------------|
while I'm concatenating 3 columns and creating a column as 'item_no' (value 234-34-6783), it throws an error when I'm using the new column item_no in group by function - 'Invalid table alias or column reference' Could someone help me with this?
select dept, class, item, concat(dept, '-', class, '-', item) as item_no, sum(sales)
from sales_table
group by dept, class, item, item_no;
column data types are smallint