Skip to content
Advertisement

Tag: postgresql

Postgresql – Compare a string with a null value

I’m a bit puzzled because I believe the answer to this question is fairly simple but I’ve searched and tried several options and couldn’t find the right answer. The database is a PostgreSQL 13.1 I am using an API which sends a JSON object to a stored function in the database as follows: The function queries a table with the

sql get balance at end of year

I have a transactions table for a single year with the amount indicating the debit transaction if the value is negative or credit transaction values are positive. Now in a given month if the number of debit records is less than 3 or if the sum of debits for a month is less than 100 then I want to charge

how to select set of records is ID is present in one of them

Here is the table where ORGID/USERID makes unique combination: I need to select all records (organizations and users) wherever USERID 1 is present. So USERID=1 is present in ORGID 1 and 2 so then select all users for these organizations including user 1 itself, i.e. Is it possible to do it with one SQL query rather than SELECT *.. WHERE

How to perform query on two unrelated tables

I have a table A with Id and Geometry And Temporary table B Each Geometry of Temporary table B has intersecting geometry in Table A. I want to find the intersecting geometry and make a union of the geometry. The final table should be id of Table A which is having intersection and the union of geometry. If there are

SQL: Retrieve missing values from superset

I have a table like this: I want to return a table with all the ratings possible. In this case 1 to 5. So my resulting table will be: I have tried using something like: but this does not work. Can you please suggest a solution for this? Answer You can cross join the list of distinct devices with numbers

Advertisement