Skip to content

Tag: oracle

SQL query to get the output

I have two tables Table A and Table B as listed below. What is the SQL query to get the below output? Answer This looks like a cross join, to generate all possible combinations of rows between the two tables. Assuming a structure like tablea(col), tableb(col): If you want to concatenate the results in a singe…

SQL loop through columns with name to find max date

I’m looking for the SQL to loop through 20 columns with dates, to find the max. My code is kind of bad now: it’s oracle database, i konow that max date is in filed annex_20 Answer First of all, you don’t need ANNEX_XX_DATE is not null since ANNEX_XX_DATE<>… can’t be true if…

Oracle “NOT IN” not returning correct result?

I’m comparing two tables that share unique values between each other using NOT IN function in Oracle but I’m getting the output is: 521254 for all charging ids –< this is the total unique charging ID’s in BILLINGDB201908 Now I want to find id’s in table BILLINGDB201908 that al…

Oracle SQL query times in one line

I apologize in advance for any formatting issues. Here is some sample data. Here is what I would like to produce: Here is what I get when I use a series of case when statements Any coding help is much appreciated. Answer That is what the PIVOT clause was created for:

Filter out records that are not in this date format oracle

How do i filter records that can only be converted to date using to_date(’31-May-2019 00:00:00′, ‘DD-MON-YYYY HH24:MI:SS’) from the above sample query i am expecting results below how do i achieve this in oracle. Reason why i want to do this: i am receiving raw data and loading it to a…