Skip to content

snowflake substring by pattern

I have a string column in my table as below: i need a dynamic way of only extracting 123456 from these string. Can you plz suggest a solution. Answer Use the REGEXP_SUBSTR(…) built-in function to extract substrings using a regular expression pattern. If there will only be one number in each column value, a nu…

need to form SQL join/subQuery on multiple tables

There are 3 tables – tables — columns ABC – abc_id, abc_name, active_flag XYZ – xyz_id, xyz_name, active_flag ABC_XYZ – abc_xyz_id, abc_id, xyz_id, active_flag id column in each table is PK I need to form a query which will return output like – for each abc_name there will …

Select the most popular month

This is my sample data. I want to select the most popular month for borrowing. This is what I’ve tried so far: Answer In SQL Server, you can use select top (1): If there are ties, this returns an arbitrary matching row. If you want all of them, use TOP (1) WITH TIES.

Oracle 12c updating multiple rows with the same data

I’m trying to write a script that pulls out all of the distinct ‘words’ in a string and saves them in another field. I’ve gotten the process to work in Oracle 19c (though any advice is welcome) but when I run the script in 12c the first record is correct but all the following records h…