Skip to content

Tag: case

Oracle decode equivalent function to Postgres

So, I’m in migrating database from oracle to Postgres, and this is my error: and here’s my code : do you have any clue? From what I’ve read, some say to replace the decode function with COALESCE, but I don’t have any idea how the syntax is. Answer You could use a standard case expression:

Simple SQL CASE Question – from WHERE to CASE function

Sorry for the noob question, new to SQL here and would appreciate help ๐Ÿ™‚ I have this SQL query: Will I have the same result if I use this query? (Am I applying the case function correctly here?) If not, can someone help me fix the query below, if possible? *EDIT The original query actually went like this, and I

Mapping two columns into one column in Athena

I have data in the Athena something like this: However, the table owner changed the provider to provider_new. Thus, after 2020-08-01 the provider returns to NULL. Here is my query: How can I map these two columns to one? Thanks in advance. Answer Do you want coalesce()? coalesce() returns the first non-null value of the arguments it is given.