Group by is grouped by one field, but select has multiple fields?

problem description

as follows, I created an attempt. I want group by to group the sum by RD.SKU and the RD.QTYRECEIVED field is sumsum, but I want to display the six fields of select instead of just showing RD.SKU and sumsum,. The simple point is, the sumsum field wants to implement the RD.QTYRECEIVED and

of the same RD.SKU.

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

CREATE OR REPLACE VIEW aaa AS
SELECT

   R.WHSEID,
   RD.STORERKEY,
   RD.SKU,
   RD.QTYRECEIVED,
   RD.LOTTABLE04+8/24  AS  LOTTABLE04,
   sum(RD.QTYRECEIVED) as sumsum    

FROM. Omit the associated table
group by

   R.WHSEID,
   RD.STORERKEY,
   RD.SKU,
   RD.QTYRECEIVED,
   RD.LOTTABLE04;

what result do you expect? What is the error message actually seen?

May.12,2021

I see you asked a similar question, but no one answered it. The main reason is that the description of the problem is not clear, and people can't start if they want to answer it.

I can only tell you the basic use of group by: the fields in the
group by clause are used as grouping. In the example you give, there are three fields: R.WHSEIDmRD.STORERKEYGRD.SKU. The remaining two fields are calculated fields and should not be placed in the group by.

after using the group by clause, the fields after the select clause can only be fields that appear in group by, or can be calculated through aggregate functions (min,max,avg, etc.).
in the example you gave,: sum (RD.QTYRECEIVED) is correct;
the following two fields are incorrect and need to add aggregate functions (min,max,avg, etc.), because there are multiple data in the same group after group by, and the database cannot determine which record to take.
RD.QTYRECEIVED,
RD.LOTTABLE04+8/24 AS LOTTABLE04

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37077-4ecc6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37077-4ecc6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?