673,688 questions
Score of -1
0 answers
74 views
Insert record with foreign key if primary key is missing or not?
I have two tables with a primary-foreign key relationship.
A value in the foreign key table must be present in the primary key table.
What is a stored procedure to insert a record into the foreign key ...
Score of -5
0 answers
79 views
Optimize query to reduce the downtime [closed]
I need suggestions on optimizing this query.
These are basically to find gaps between the db
SELECT
c.id AS claim_id, -- parent key
c.file_number,
ca.id AS ...
Score of 0
2 answers
103 views
Create a query with columns containing sums of values from a table
I have a table with 3 columns:
Part Number
Location (where the part number is stored - 4 cities "London, Paris, Rome, New York")
Quantity (how many products are stored in that location)
I ...
Score of -3
1 answer
107 views
Invalid date syntax in PostgreSQL [duplicate]
This query runs fine:
select *
from "rwPower-Chassis-Lpars"
where "Date" = (('yesterday')::date - interval '1 day')::date
This one gives me an error:
select
'a.Chassis_Id'
,'...
Score of 0
2 answers
118 views
Sakila customer who has paid the most using subquery max of all the sums
I found a query: SELECT name from table WHERE scalar subquery is true
where the user wants a single customer name who has paid the most.
I am trying to understand and rebuild the first solution posted ...
Score of 0
0 answers
46 views
Store a multi char prompt into a variable in SQL under BO
With WebIRC (v4.3 SP2 with Oracle 19), I want to have in the report a variable containing the list of the selected values in the prompt pop-up.
I tried this (simplified code) :
SELECT
REFERENTIEL....
Score of -3
1 answer
204 views
How to INSERT a string that is similar to a JSON structure [closed]
I have a string that looks like this in a flutter app:
[ { Pallet: 1, Loaded: , LoadedTimestamp: },
{ Pallet: 2, Loaded: "True", LoadedTimestamp: "2026-07-27 12:00 AM" } ]
I am ...
Score of 0
2 answers
174 views
Error Code 1054 unknown column in 'field list' error without Group Concat Actor
I am playing around with the Sakila database. There is a view in this database named film list.
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `sakila`.`film_list` AS
...
Score of -1
1 answer
132 views
Trouble with SELECT COUNT and GROUP BY
I am adding data to a table I created with an INSERT INTO statement in SQLite. When I enter the code below (minus ~~ubicageo~~ in the SELECT TOTAL row) within parenthesis, the code fails to group the ...
Score of 0
2 answers
165 views
DB2/LUW v11.5.9 Collation names for COLLATION_KEY() function?
Anybody know where I can get a list of the valid collation-name values for the COLLATION_KEY function in DB2/LUW?
The situation is that I am pulling a DB2/LUW result set up to a mainframe for ...
Score of 1
2 answers
86 views
CURSOR not supported in Azure Synapse Dedicated SQL Pool — correct WHILE loop pattern for iterating sys.tables discovery result?
I am writing a stored procedure in Azure Synapse Analytics Dedicated SQL Pool that auto-discovers all user tables in a given schema via sys.tables / sys.columns, then executes parameterised dynamic ...
Score of 2
2 answers
157 views
Add 2 columns together from different tables and avoid NULLs [duplicate]
I'm trying to add the rows of 2 nearly identical tables together to produce a sum of those two rows and am experiencing a NULL for one item that only appears in one of the tables, when I would hope to ...
Score of -3
2 answers
113 views
Convert string to native date object
I am working with a public dataset in Google BigQuery where date values are stored as string text (e.g., '2026-07-22') rather than native DATE objects. I need to convert this column into a standard ...
Score of 0
0 answers
161 views
AUTOINCREMENT order inside one multi-row INSERT
If I do this:
CREATE TABLE `MyTable` (
`Id` INTEGER PRIMARY KEY AUTOINCREMENT,
`Name` TEXT
) STRICT;
INSERT INTO `MyTable` (`Name`)
VALUES ('Alice'), ('Bob');
in SQLite, I expect that Alice will ...
Score of 3
1 answer
151 views
Find identical aggregated combinations from pivot table in SQL
Background
I’m updating a very old website which has a tagging feature for objects. The tags are divided into nine separate semantic categories and can be related to objects via a pivot table. There ...