674,690 questions
0
votes
1
answer
15
views
PostgreSQL correlated query ignore WHERE clause (runnable example)
For each customer_id, I want to find the first delivery order. To do this, for each row of Delivery, I compare order_date with the smallest order_date of that customer_id.
However, using the SELECT ...
0
votes
0
answers
20
views
Db2 for i SQL0904 (CPD4365 Reason Code 3): “More than 65535 bytes in an internal buffer” when selecting many columns
We have an SQL SELECT statement that retrieves over 400 fields from more than 120 joined tables. The query executes successfully on other database systems (Oracle 19c and Microsoft SQL Server 2019). ...
-3
votes
1
answer
50
views
Find Previous Non-Null Value in table with many products [closed]
I am trying to correct where NULL values exist in an inventory table by returning the previous known balance when NULLs exist. There are many products in this table.
For example,
2023-01 balance ...
0
votes
0
answers
61
views
Firebird WHERE IN clause with string parameters [duplicate]
I try to pass string values in a sql query but with no luck
Values are for example 'CAR, TREE, HOUSE' etc user can freely choose these values 1, 2 ore more. So my creation string contains only the ...
0
votes
0
answers
81
views
Return multiple columns with aggregate functions [duplicate]
I am trying to figure out how to return multiple columns that correspond with the desired aggregate functions, max of a sum, in SQL.
Based on data from CDC's Serotypes of concern: Illnesses and ...
1
vote
2
answers
107
views
Query upcoming birthday date
My table looks like
ID | PersonName | Birthday | IntDate
--------------------------------------
1 | Joe | 1977-08-20 | 820
2 | Sandy | 1985-02-27 | 227
3 | Jane | 1981-...
0
votes
0
answers
51
views
Composite key (ts, deviceid) with timeseries container
I’m on GridDB Cloud (Free). For a TimeSeries container, I want each device to have at most one row per timestamp, i.e., enforce uniqueness on (ts, deviceid).
Schema:
CREATE TABLE TSDB (
ts TIMESTAMP ...
0
votes
0
answers
78
views
Create a column to have a foreign key to the union of two other columns [duplicate]
I have a table
CREATE TABLE Person (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
home CHAR(2) NOT NULL
);
where I would like the values of home to be either a country code or a ...
-2
votes
1
answer
78
views
Update by comparing data in 2 tables [duplicate]
I have two tables in my database: wp_posts and wp_postmeta.
I want to retrieve the "meta_value" value of a column in wp_postmeta based on the "meta_key" data. So I want to get the &...
-4
votes
1
answer
79
views
Editing data in one table according to the data status in another table [closed]
I have two tables in my database: wp_posts and wp_postmeta.
wp_postmeta, wp_posts
I want to retrieve the "meta_value" value of a column in wp_postmeta based on the "meta_key" data....
3
votes
2
answers
93
views
Mark rows within comments
I have a table like this:
name
line
text
aaa
1
some text
aaa
2
/* some text */
aaa
3
some text
aaa
4
/*
aaa
5
some text
aaa
6
some text
aaa
7
*/
aaa
8
some text
aaa
9
/*
aaa
10
* some text
aaa
11
* ...
-1
votes
0
answers
78
views
Why are parenthesis in my where clause changing my result? [closed]
I have this query in BigQuery:
SELECT
ne_mapping_id,
billing_country,
shop_id_clean,
sum(revenue) AS revenue
FROM `ne-liftclients.dbt_abanderasnewengen_intermediate....
0
votes
0
answers
60
views
Referential Integrity in relation to user-defined data
I have a simple budgeting app that allows users to define their own accounts and categories and a few other columns.
Those items they then define are used in their own personal budget.
I want to use ...
0
votes
1
answer
62
views
What is the correct syntax for selecting data between NOW() and the previous hour in griddb/griddbCloud?
Considering that GridDB does not provide an INTERVAL keyword and will result in a syntax error, what is the correct syntax for selecting data between NOW() and the previous hour in GridDB/GridDB Cloud?...
1
vote
1
answer
78
views
Using a schema as a parameter in stored procedure
So my application has the following two functions. However I would like to execute the sql in the lld_comparison_graph_data function as a stored procedure.
def lld_comparison_graph_data(self, firm, ...