I am trying to select list of employees, but i know some employees do not have manager_id, for these employees without manager_id (null) i want the result to display “pip” while for the rest it displays original info. Answer The code you want is probably: Or more simply: The two significant issues…
Tag: postgresql
select random COLUMN from PostgeSQL
I have a table which contains some links to photos in a few columns and I need to get a random photo from it. gives me a 3 links. But can I get only 1 random out of it? Answer You can unpivot. For instance: If the columns can ever be NULL, then you might want WHERE v.photo IS NOT
How do you I calculate the difference between two timestamps in PostgreSQL?
I have a SELECT query to retrieve data I need. One of the needed data is a an “aggregate” function to select two timestamp dates and calculate the difference between them. Using several resources and websites, they all gave me save answer and it did not work: I’m getting an error on the R…
How to show decimal value separately in PostgreSQL?
I have a table named c_price and have a column value like below in PostgreSQL. Now need a query for below result. Answer trunc() and mod() may be used dollars | cents ——: | —-: 123 | 67 db<>fiddle here
I am having issues with a syntax error in PostgreSQL. I am trying to add a query and it is giving me an error
I am taking a Data Analysis Course on Udemy. I am using PostgreSQL. On one of my exercises, I tried to add a column of data and recieved a Syntax Error Message. Here is a screen shot of my code: can …
Check attribute in trigger function (PostgreSQL)
I have a task in school which requires me to create a table and a trigger. I don’t really know how to explain it but how can I check if cID is inside the select statement within the trigger function ? …
PostgreSQL Integer in Array is not merge-joinable
I would like to perform a FULL OUTER JOIN ON a condition that is an integer being in an array of integer. The query would look something like this: SELECT thing FROM table1 t1 FULL OUTER JOIN table2 …
How to format in PostgreSQL CITEXT variable to a regex to be used for search
First of all – all credits goes to Laurenz Albe answer here I hava a JSONB colum where I need to perform a search on the values (exactly as explained in the linked question). I think to get advantage …
postgres procedure list of values
I’m trying to pass in a list of values into a Postgres 11 procedure. The query has an IN condition. How do I pass in a list of values to the procedure & then how do I use it in the query? create …
How to edit my postgreSQL query to select the most recent row by date for several columns
I have a query where I’m trying to select the most recent row based on date. So what I would like my query to do is to select the most recent datapoints for a couple columns in my database. sql = f&…