When I write an SQL statement today
Select sum (. plate), sum (. qty), sum (. qly),. materialtypeid, B. name, B. spec, from fw_eqpres_materialinventory a, fw_eng_material B where. materialtypeid = B. sysid
And B. name like '% XX %'
Group by a. materialtypeid
Prompt not a single group by function
But write
Select sum (. plate), sum (. qty), sum (. qly),. materialtypeid, B. name, B. spec from fw_eqpres_materialinventory a, fw_eng_material B where. materialtypeid = B. sysid
And B. name like: name
A. materialtypeid, B. name, B. spec
There is no error, so the relevant information is explained as follows:
Select state_cd, avg (sales) from customer group by state_cd;
Most people start to understand the meaning of the groupby statement, but it is often troublesome to use. Make sure that group by references the correct number of columns in each statement. It is prompted that when group by is used, the columns not used in the group by section must use the grouping function when the select part appears.
Ignore the problems that may occur when grouping functions are used. If the statement is executed:
Select last_name, state_cd, sum (sales) from customer
Group by last_name;
The following error is returned:
ERRORatline1:
ORA-00979: notaGROUPBYexpression
This is because the group by clause is not used in the state_cd table column, so the grouping function must be added. In other words, you must use the max (), min (), sum (), count (), or avg () functions. If you cannot find the appropriate grouping function for the specified table column, move the table column to the group by clause.