Hi
I have below data . I have group by itemcode,batch no, warehouse. . In below case Batch no 4330 has 2 records with 2 Bin No I want to concat these 2 records.
| Item Code | Batch No | Bin No | Warehouse Code |
| 8 | 4330 | 242 | 82 |
| 8 | 4330 | 194 | 82 |
| 8 | 6527 | 194 | 82 |
| 8 | 6527 | 242 | 82 |
| 8 | 6648 | 242 | 82 |
| 8 | 7444 | 242 | 82 |
| 8 | 8567 | 242 | 82 |
| 8 | 8987 | 242 | 82 |
| 8 | 9743 | 242 | 82 |
It should display like this
| 8 | 4330 | 242,194 | 82 |
| 8 | 6527 | 194,242 | 82 |
Thanks
Muhammad Imran AnsariPosted Feb 14, 2025, 10:46 AM
Hello Ramco,
In SQL, you can use the
STRING_AGGfunction (in SQL Server 2017+) to concatenate the "Bin No"values for each group. Below is the examples:Good Luck!
Eliana BlakePosted Feb 14, 2025, 8:14 AM
Based on the data provided, it seems like you are looking to concatenate the Bin No values for records with the same Item Code, Batch No, and Warehouse Code. This can be achieved through SQL queries using GROUP BY and STRING_AGG functions in databases like SQL Server.
Here's an example of how you can concatenate the Bin No values based on your sample data:
This query will group the records by Item Code, Batch No, and Warehouse Code while concatenating the Bin No values separated by a comma.
By running this query on your dataset, you should get the desired output where the Bin No values are concatenated for records sharing the same Item Code, Batch No, and Warehouse Code.
If you need further assistance or have a different database system in mind, feel free to provide more details for a more tailored solution.