October 22, 2024
Chicago 12, Melborne City, USA

SQL

Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample dat

SQL

Getting Table Column Value Based on Dynamic Column Name

I have a ‘column specifier’ table that specifies the names of 1 or more columns of a source table that contain the data needed for stuff. The list of columns required depends on various things, but here, it depends only on what I’m calling the ‘cid’. I must retrieve the values found in each column

Read More
SQL

Counting Active Transactions in SQL: Issues with Status Logic in Time Series Data

I am trying to create a SQL query to count active transactions month by month from a transaction_status table. Each transaction_id can have multiple statuses, with two key statuses: ENDORSEMENT_SUCCESS (when the transaction is active) and ENDORSEMENT_CLOSED_SUCCESS (when the transaction is closed). Problem: The challenge I’m facing is ensuring that: A transaction should only be

Read More
SQL

sqlplus: how to execute a query spanning multiple lines

I am using Oracle 19c. I can get the following to work: variable max_id number; exec select 41 into :max_id from dual; begin dbms_output.put_line(:max_id); dbms_output.put_line(:max_id+1); end; But splitting the select across multiple lines produces an invalid SQL statement error at the new line: variable max_id number; exec select 41 into :max_id from dual; -- invalid

Read More
SQL

I need to replace old path's images to new path with the same image

I have a column Path_Image in table DBPaths : Path_Image C:\Users\Pc\Desktop\archive\1.png D:\pics_back\22.jpg C:\Users\Pc\Desktop\archive\947141.JPG And I have a new Path: E:\pics2024 I want to replace all old paths with a new one without touch images , like this : Path_Image E:\pics2024\1.png E:\pics2024\22.jpg E:\pics2024\947141.JPG The question is that possible and how I can do it , for

Read More