clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 648403 fiddles created (15127 in the last week).

CREATE TABLE Inventory ( gid VARCHAR(25), version int, warehouse int, quantity int, description varchar(255) ) INSERT INTO Inventory VALUES ('gid1', 1, 1, 100, 'name 1'), ('gid1', 1, 1, 200, 'name 1'), ('gid2', 1, 2, 200, 'name 2')
3 rows affected
 hidden batch(es)


SELECT gid, version, warehouse, description, SUM(quantity) as total FROM Inventory GROUP BY gid, version, warehouse, description;
gid version warehouse description total
gid1 1 1 name 1 300
gid2 1 2 name 2 200
 hidden batch(es)


SELECT DISTINCT T1.gid ,T1.description ,T1.version ,T1.warehouse ,T2.quantity FROM Inventory T1 INNER JOIN ( SELECT gid, version, warehouse, SUM(quantity) AS quantity FROM Inventory GROUP BY gid, version, warehouse ) T2 ON T1.gid = T2.gid
gid description version warehouse quantity
gid1 name 1 1 1 300
gid2 name 2 1 2 200
 hidden batch(es)