Skip to content

Oracle case statement not returning values for no row results

I have a simple case statement as follows: This code is designed to return ‘A_VALUE_ANYWAY’ because there is no output from the SQL. However, it does not return anything at all. Essentially, what I would like is a value being forced to return from the case statement instead of just no rows. Am I a…

SQL how to select distinct several columns

lets say there are several columns (c1, c2, c3, c4) It’s okay for each column to be appeared several times, but I want to select all the columns with several columns distinct. I want SELECT c1, DISTINCT(c2, c3), c4 something like this but it doesnt work, and GROUP BY doesnt work as well. somebody help m…

Get records greater than 1 for same status

I have table logs Table 2 status_master So, now I’m trying to get the retry count for each scenario. Expected result Answer Sounds like an aggregation of an aggregation to me. Try: Results status count 2 1 19 1 My results were different than your expected results. Did you mean for status = 1 to be statu…

SQL Oracle fusion lines with same id

Here is a simplification of my problem: I would like to have a result like this (keeping those 2 selects): Not sure how to fusion those 2 lines One ugly solution is: Answer For me it looks like a join with nvl for me: I’m not sure about your data, so probably it should be just left/right join or even

Create table in snowflake – Syntax

I am trying to create a table and insert rows into it. But it keeps giving me this syntax error. ERROR : SQL compilation error: syntax error line 3 at position 1 unexpected ‘EventName’. syntax Any help would be appreciated. Answer You need to type those columns, and you are missing a comma after t…

SELECT a query after another SELECT using Dates

i have a table that uses TIMESTAMPS an needs to be filtered by month, the query is: now, from the results of this query i need to use another query that groups the dates by day and makes a sum of a field, in the same table: How can i join this two querys so the two separated queries can