31 questions from the last 7 days
-1
votes
0
answers
41
views
Problem adding argument in the function with other default parameters [closed]
I am using PostgreSQL 18.0 and I have written a function with default parameters which inserts movie into the table. However, when I add the argument which must be added, it gives error:
SQL Error [...
0
votes
1
answer
60
views
Calculate percent of total per firm and filter firms above 50%
I'm trying to calculate the percentage contribution of each firm to the total amount across all firms.
Database:
google-bigquery
What I need (desired output):
Sum usde_haircut_amt per firm
Compute ...
-2
votes
0
answers
75
views
Oracle: how to filter for the partial date from any string appear in the column? [closed]
I have a case where I need to filter for the partial date string from a column.
Here is the input:
date_value
-----------------------------
7-03 start 4444
03/2022 follow up
1111 7-03 03/2022 ...
0
votes
1
answer
74
views
How to remove duplicate rows based on array column subset relationship in DolphinDB?
I have a DolphinDB table with an array vector column. I need to remove duplicate rows based on subset relationships within that column.
Sample Input:
sym
prices
a
[3,4,5,6]
a
[3,4,5]
a
[2,4,5,6]
a
[5,...
0
votes
1
answer
24
views
Redshift PartiQL for unpivoting the keys and values in a Map typed SUPER
AWS documentation for querying Redshift's super is very much all in on supers that are arrays.
But, I happen to want a super that is a map, as I'm sure a number of people do, and I would like to then ...
1
vote
3
answers
78
views
How to group the data to avoid multiple rows
I have an employee Manager table where you can see for every deptID, there are multiple rows.
A few rows have null employeename and a few rows have null managername for same DeptID. i would like to ...
-2
votes
1
answer
107
views
How to display in postgresql only the records that are not within the 10 minutes [closed]
For example, I have this table below, how can I display only the records that aren't in the 10 minutes range. In this example should return the first and last in note examples
user_id | ...
-2
votes
2
answers
70
views
Oracle SQL Test to identify missing rows for unique identifier
I am trying to find an Oracle SQL to test whether a table (CONTACTS) contains two rows of data for each primary key (PK) called REF_NO.
The table has a PK called REF_NO and a second PK called CONT_IND....
0
votes
1
answer
125
views
Make MySQL evaluate subquery first
SELECT tt.trans_type_name AS transaction_type,
trans.transaction_time,
a.trans_action_name AS transaction_action_name,
trans.transaction_notes
FROM(SELECT Cast(...
1
vote
1
answer
74
views
Creating Materialized view in PG 17 ignores data types in SELECT
I have the following SQL to create a materialized view and the SQL seems reasonable to me but it's unclear from Postgres docs what should happen in this case.
I am listing the columns when creating ...
1
vote
1
answer
112
views
Postgres Recursive Query Behavior
I have a table test with two columns, each referencing the other
ID1
ID2
2
1
3
2
4
3
5
4
Given an id, I need to traverse the chain to return all the rows traversing the chain. Below is the query I ...
Advice
2
votes
7
replies
101
views
Splitting SQL output evenly into 3 HTML columns
I am trying to take the output of a SQL query and split it evenly into 3 HTML columns such as flexbox divs. Obviously the output total won't always be evenly divisible by 3 and the first 2 totals ...
0
votes
1
answer
72
views
Why are my data quality validation rules not triggering for null values in my dataset?
I’m working on a data quality workflow where I validate incoming records for null or missing values.
Even when a column clearly contains nulls, my rule doesn’t trigger and the record passes validation....
2
votes
1
answer
115
views
SQL: Calculating percentage of time spent in a country
I have this table in SQL:
CREATE TABLE myt (
name VARCHAR(20),
country VARCHAR(20),
date_arrived DATE,
date_left DATE
);
INSERT INTO myt (name, country, date_arrived, date_left) ...
3
votes
1
answer
92
views
Cause of and means to avoid "flat BNL join" in mariadb 10.11
I'm trying to help a user in another stackoverflow question and have bumped by head into a strange behaviour.
As I rarely use MariaDB, I'm opening another question to investigate the behaviour,
...
3
votes
3
answers
129
views
How to retrieve a sub-array from result of array_agg?
I have a SQL table in postgres 14 that looks something like this:
f_key
data1
data2
fit
1
{'a1', 'a2'}
null
3
1
{'b1', 'b2'}
{'b3'}
2
2
{'c1', 'c2'}
null
3
Note that data1 and data2 are arrays.
I need ...