Skip to content

Tag: sql

PLSQL – Use variable array on where clause IN

I am looking to use an array of values in the WHERE IN condition. After research, I saw that I had to make a “CREATE TYPE”, since a “TYPE” in local does not work. This solution does not suit me, I do not want to make a new TYPE in Oracle, since the database is used for an ERP/PGI I

Select second most recent date from inner join

I have this query : I get this result : How can I select only the second most recent created_at date from each unique display_name ? Answer You could use row_number to assign a sequence to your dates and apply this before joining, then include as part of your join criteria, such as: You could also apply this …

Concatenate values of two consecutive rows SQL

I want to write a SQL query to concatenate row values of 2 consecutive rows as described below: I have the below table: I want to have another column as below: The concat value is the concatenation of serial_no value in row 2 with the serial_no value is row 1, serial_no value in row 3 with the serial_no value…

SQL Server : how to group only part of the syntax

I have a problem creating a SQL Server query. In summary, the query should get columns that are sum and count, grouped by customerID, and another column that is a case when by a column that is not used as a grouper column. My problem is to group only part of the syntax, while the case when column does not

Hierarchy Queries in BigQuery

I have a data from ControlM (scheduler) this way I saw many solutions where they have started from first node and descended to last node. But that is likely to fan-out with this data. What I am looking for a fan-in solution, where I can start with any end node and come towards first node In this case the answ…