Hi
I have Table OWHS with 2 fields BPLId,WhsCode. I want all those records with Branch having more than 1 Warehouse Code
Thanks
Hi
I have Table OWHS with 2 fields BPLId,WhsCode. I want all those records with Branch having more than 1 Warehouse Code
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Emily FosterRank #3,495 · 415 reputationPosted Mar 26, 2025, 1:08 AM EDT
Hello! It sounds like you are looking to retrieve specific records from the OWHS table based on the condition of having more than one Warehouse Code associated with a Branch.
To achieve this in SQL, you can use a GROUP BY clause along with the HAVING clause to filter the results based on the count of Warehouse Codes associated with each Branch. Here's an example query that might help you accomplish this:
SELECT BPLId, COUNT(WhsCode) as WarehouseCount FROM OWHS GROUP BY BPLId HAVING COUNT(WhsCode) > 1;In this query:
- We are selecting the BPLId field and counting the number of WhsCode values associated with each BPLId using the COUNT function.
- The GROUP BY BPLId groups the records by Branch, and the HAVING clause filters the groups to only include those with a Warehouse Count greater than 1.
Running this query will give you the Branches along with the count of Warehouse Codes for each Branch where the count is more than one.
If you have any specific database system in mind (e.g., MySQL, SQL Server, Oracle), you may need to adjust the syntax slightly based on the SQL dialect supported by that system.
I hope this explanation and example help you in retrieving the desired records from your OWHS table. Let me know if you need further assistance or have any other questions!
Sangeetha SRank #212 · 11.4K reputationPosted Mar 26, 2025, 1:10 AM EDT
To retrieve records from the
OWHStable where a branch (BPLId) has more than one warehouse code (WhsCode), you can use SQL to group the records byBPLIdand filter those groups having more than oneWhsCode. Here's a query that should help:SELECT BPLId, WhsCode FROM OWHS WHERE BPLId IN ( SELECT BPLId FROM OWHS GROUP BY BPLId HAVING COUNT(WhsCode) > 1 ) ORDER BY BPLId, WhsCode;