You must put all columns of the SELECT
in the GROUP BY
or use functions on them which compress the results to a single value (like MIN
, MAX
or SUM
).
A simple example to understand why this happens: Imagine you have a database like this:
FOO BAR 0 A 0 B
and you run SELECT * FROM table GROUP BY foo
. This means the database must return a single row as result with the first column 0
to fulfill the GROUP BY
but there are now two values of bar
to chose from. Which result would you expect – A
or B
? Or should the database return more than one row, violating the contract of GROUP BY
?
Related Posts:
- ORA-00904: invalid identifier
- how to fix oracle ORA-01722 invalid number error
- ORA-00907: missing right parenthesis
- How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?
- ORA-01843 not a valid month- Comparing Dates
- ORA-00918: column ambiguously defined in SELECT *
- Oracle error : ORA-00905: Missing keyword
- How do I limit the number of rows returned by an Oracle query after ordering?
- Oracle SELECT TOP 10 records
- Can a foreign key be NULL and/or duplicate?
- How to Select Top 100 rows in Oracle?
- ORA-12560: TNS:protocol adaptor error
- ORA-00972 identifier is too long alias column name
- Oracle Apex column link from LOV values
- PLS-00103: Encountered the symbol when expecting one of the following:
- What’s the difference between RANK() and DENSE_RANK() functions in oracle?
- ORA-00918: column ambiguously defined in SELECT *
- ORA-00918: column ambiguously defined in SELECT *
- Oracle – ORA-01489: result of string concatenation is too long [duplicate]
- ORA-01861: literal does not match format string
- What is it exactly a BLOB in a DBMS context
- “ORA-01438: value larger than specified precision allowed for this column” when inserting 3
- How do you create a temporary table in an Oracle database?
- Oracle “Partition By” Keyword
- How to insert date values into table
- Oracle SQL: Update a table with data from another table
- SQL selecting rows by most recent date with two unique columns
- ORA-06502: PL/SQL: numeric or value error: character string buffer too small
- Comparing Dates in Oracle SQL
- Convert timestamp to date in Oracle SQL
- How do I reset a sequence in Oracle?
- Update statement with inner join on Oracle
- MySQL equivalent of DECODE function in Oracle
- Oracle: If Table Exists
- DATEDIFF function in Oracle
- How to create id with AUTO_INCREMENT on Oracle?
- LEFT function in Oracle
- What is the difference between Views and Materialized Views in Oracle?
- How do I view the Explain Plan in Oracle Sql developer?
- ORA-01779: cannot modify a column which maps to a non key-preserved table
- ORA-01735: invalid ALTER TABLE option – Toad
- ora-06553 pls-306 wrong number or types of arguments in call to ‘ogc_x’
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- SQL WITH clause example [duplicate]
- The wait operation timed out. ASP
- SQL query to select dates between two dates
- MySQL – Operand should contain 1 column(s)
- SQL SELECT WHERE field contains words
- Must declare the scalar variable
- How can I do a FULL OUTER JOIN in MySQL?
- How do I escape a single quote in SQL Server?
- T-SQL split string based on delimiter
- Finding duplicate values in a SQL table
- MySQL Cannot Add Foreign Key Constraint
- How do I import an SQL file using the command line in MySQL?
- SQL not a single-group group function
- How do I do multiple CASE WHEN conditions using SQL Server 2008?
- Difference between JOIN and INNER JOIN
- SQL error “ORA-01722: invalid number”
- What is the difference between JOIN and UNION?
- MySQL Multiple Joins in one query?
- “CASE” statement within “WHERE” clause in SQL Server 2008
- What does the following Oracle error mean: invalid column index
- What is the difference between Scope_Identity(), Identity(), @@Identity, and Ident_Current()?
- Combining “LIKE” and “IN” for SQL Server
- SQL Server WITH statement
- How to SUM two fields within an SQL query
- DateTime2 vs DateTime in SQL Server
- Algebra Relational sql GROUP BY SORT BY ORDER BY
- What is the equivalent of ‘describe table’ in SQL Server?
- Add a column with a default value to an existing table in SQL Server
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- Using group by on multiple columns
- What is the purpose of using WHERE 1=1 in SQL statements?
- How do you force mysql LIKE to be case sensitive?
- What is the difference between a stored procedure and a view?
- Bulk load data conversion error (truncation)
- How to order by with union in SQL?
- PostgreSQL create table if not exists
- Incorrect syntax near ”
- MySQL: Can’t create table (errno: 150)
- GROUP BY and COUNT using ActiveRecord
- MySQL – Get row number on select
- What does * mean in sql?
- How to truncate the text returned for a column in a MySQL query
- PLS-00049 bad bind variable While using :OLD
- How To Write An Inner Join With WP Query
- Update user_login, user_nicename, and display_name
- Change sticky status of posts from phpMyAdmin
- How to import a Typo3 database to a wordpress site?
- Clean up very big and very dirty database
- How can I convert everything from category X to have post format Link
- Bulk delete WordPress Post and all metadata, etc using SQL query
- Reset post IDs with all post meta
- How to Add or Change Post Title
- Why does DROP TABLE-ing the `wp_options` reset my user session?
- How to refactor DB queries for better TTFB in WordPress?
- query sql-table and change entities
- Backtick (MySQL norm) added to SQL Server Query causing error
- Firebase with WordPress instead of SQL?