674,804 questions
1
vote
0
answers
21
views
Convert Columns to Row in BigQuery for financial statement
I'm working with financial data in BigQuery, and I have a table structured like a financial statement (e.g., Balance Sheet), where account hierarchy is split across columns (Level 1 to Level 20) and ...
3
votes
1
answer
57
views
Invalid identifier when using aggregate count(*)
I need to count the number of students who were registered in a given course over an academic year.
The following SELECT query returns a column of course numbers and a column of the academic year.
...
1
vote
1
answer
51
views
Setting the counter of one table equal that of another doesn't work as expected
I have two tables in a SQLite database:
CREATE TABLE IF NOT EXISTS "DVDsBluRays" (
"dbd_Title" TEXT,
"dbd_DateBought" TEXT,
"...
-5
votes
0
answers
63
views
Adding condition for SQL output [duplicate]
I have table which has
id
context
user_id
1
a
aaa
2
b
bbb
3
c
aaa
4
d
ccc
5
e
aaa
select count(user_id), user_id
from context
group by user_id;
It returns like this, how many rows for each users.
...
-5
votes
1
answer
83
views
Get the latest record for each user_id based on a timestamp column [closed]
I have a table where each user_id can have multiple activity records with timestamps. I want to retrieve only the latest record for each user, based on a timestamp column like activity_time.
How can I ...
0
votes
4
answers
156
views
Partial matching on strings
In SQL Server I have a table of bank transactions, and a table of payees. I want to link the transaction to the correct payee. I have used CHARINDEX (PayeeName, TxnDescription,1) > 0 to find the ...
-1
votes
1
answer
79
views
Grouping data using the LEAD() function
I've got this query:
SELECT TOP (1000) [TRANS_ID]
,[VSN_VENDR_EFF_DT]
,LEAD([VSN_VENDR_EFF_DT], 1, '2025-08-07') OVER (ORDER BY [ACCT_NUM],[VSN_VENDR_EFF_DT]) AS NEXT_EFF_DT
,[...
3
votes
4
answers
135
views
Combine rows to remove nulls or swap row values if not null
Input table:
ID Account Contact
-----------------------
ID1 A11 C11
ID1 A12 NULL
ID2 A21 NULL
ID2 A22 C22
ID3 A31 C31
ID3 A32 C32
Output needs to be like this
ID Account Contact
-------------------...
-5
votes
0
answers
35
views
Split single Json string values into multiple rows in databricks SQL
My complete JSON string is stored in a single column in my Databricks SQL table. I was trying to split the arrays into separate rows from this string.
This is what's stored in my Databricks lake table:...
0
votes
3
answers
108
views
SQL Calculate Running Total Against Positive Transactions
I have an instance where I need to be calculating the running total by positive transactions. This exercise is to determine which positive entries in our warehouse entries is still open as we need to ...
0
votes
1
answer
35
views
Check referential integrity between two GridDB containers
I have two GridDB Cloud containers participating in a one-to-many relationship. The tables layout is shown below:
Table Customer (collection container)
Name
Type
Nullity
Key
Customer_ID
INTEGER
NOT ...
0
votes
1
answer
130
views
How to pass vector from Python to Duckdb for vector similarity search
I am using Duckdb with the VSS extension to store document embeddings, it works normally however when I try to do a similarity search to a vector passed from Python, I am getting a TypeError. The ...
0
votes
3
answers
62
views
pg8000 conn.run argument error/ SQL syntax issues inserting data with AWS Lambda
I am using AWS Lambda with Python and pg8000 to insert records into a PostgreSQL RDS database.
When conn.run() is called, I get argument errors or syntax errors.
INSERT_SQL:
INSERT INTO crypto_prices (...
-1
votes
1
answer
79
views
Typeorm where case condition
Got table with id, price, priceTo columns. priceTo column is conditional null.
Use typeorm build query.
Need to get rows, by the price value and conditional priceTo column. If it is not null, then use ...
-1
votes
0
answers
49
views
psycopg2.errors.SyntaxError: syntax error at or near "'Klines'" [duplicate]
Can't create a new PostgreSQL table because of this error. Here is the code that I use to create a new table:
class KlineTable(TableInterface):
def __init__(self):
super().__init__()
...