Results for “INSERT”
Small, practical examples. Search by task or narrow things down below.
Find rows with a related record
Use EXISTS without duplicating the outer rows.
EXISTS✓ Tested
Find the second-highest distinct value
SQL: Select the maximum below the overall maximum to skip ties at the top.
SQL✓ Tested
Find the second-highest distinct value
SQL Server: Select the maximum below the overall maximum to skip ties at the top.
SQL Server✓ Tested
Find the second-highest distinct value
Postgres: Select the maximum below the overall maximum to skip ties at the top.
Postgres✓ Tested
Find the second-highest distinct value
SQLite: Select the maximum below the overall maximum to skip ties at the top.
SQLite✓ Tested
Generate every combination of two sets
SQL: CROSS JOIN creates one result per possible pair, so the output size is the product of the input sizes.
SQL✓ Tested
Generate every combination of two sets
SQL Server: CROSS JOIN creates one result per possible pair, so the output size is the product of the input sizes.
SQL Server✓ Tested
Generate every combination of two sets
Postgres: CROSS JOIN creates one result per possible pair, so the output size is the product of the input sizes.
Postgres✓ Tested
Generate every combination of two sets
SQLite: CROSS JOIN creates one result per possible pair, so the output size is the product of the input sizes.
SQLite✓ Tested
Group by more than one field
SQL: Each distinct combination of grouping fields produces its own row.
SQL✓ Tested
Group by more than one field
SQL Server: Each distinct combination of grouping fields produces its own row.
SQL Server✓ Tested
Group by more than one field
Postgres: Each distinct combination of grouping fields produces its own row.
Postgres✓ Tested