The real situation is bigger, but I will model it like this. There are tables Name (ID, Name) and Cost (ID, Cost). You need to link them across the ID field and output the bag of goods, but you need to output not the ID but the Name. You need something like this only working)
select Name.Name, SUM(Cost.Cost) from Name join Cost on Name.ID = Cost.ID group by Name.ID If you take the real task, that is, the tables TOV, DMZ, DMS
You need to output TOV.NTOV , SUM(DMS.KOL) , SUM(DMS.CENA * DMS.KOL) (linking the tables by the fields TOV.KTOV = DMS.KTOV and DMZ.NDM = DMS.NDM ) by the given date (for example, ' 20140501 ') and by DMZ_.PR = 2 , grouping by TOV.KTOV .
Explanations: TOV - goods (identifier, name, type), DMZ - documents (date, number, type (arrival, departure)), DMS - delivery (which product, according to which document, quantity, price, type (I know what is not needed duplicate, but the task is set))

group bythis will not affect the result. Although of course it will be strange to look two lines of "beer" with some kind of data relating to different KTOV. but you have a crookedly formulated task, you can’t do anything else - Mikegroup byand get 3 lines of which 2 will be 'beer'. Or do you expect to get some other result? If so, please indicate what specific result you want to see based on the data shown. And never show the input in the form of a picture. In the text, at least you can quickly create a test database, and in the picture you need to create tables with your hands and fill them. - Mikegroup by KTOV, NTOV- Mike