Skip to content
Advertisement

Tag: postgresql

SQL query for EXCEPT or NOT IN

I’m new to SQL and I am trying to write a query on PostgreSQL to find the cust_ID and customer name of each customer at the bank who only has a loan at the bank, and no account. The database schema is: The results should have only these 3 customers: My two attempts for this query are: 1) Where my

SQL: partition by / window function with the combination of 2 columns, separated by todays date

I am trying to create a materialized-view in postgres, where I sum 2 columns, depending on todays date within a window function. In the below picture there is an example of the query I am trying to achieve: If today is the ‘2022-06-06’: 2022-06-05: 1+2+3+4+5 2022-06-06: 1+2+3+4+5+6+107 2022-06-07: 1+2+3+4+5+6+107+108 Here is a sample fiddle with date: http://sqlfiddle.com/#!15/538ea7/1 Updated: http://sqlfiddle.com/#!15/bef30/3 Would

Pivot by Country Name and Flag in Postgresql

and I am trying to cross tab it like this: Here is my SQL query, I am not able to do it since I do not have permissions to create extensions (tablefunc) Is there an alternate way? Can you please help? Thank you. Answer As you ave only 2 values, you can make the classical approach to pivot country |

change the type of column in postgres not working

I have a column of type object, and i need to make it from another object type, (the table is empty ) i tried to do : ERROR: function pg_catalog.btrim(invoice_item) does not exist LINE 1: …ory ALTER COLUMN invoice_info TYPE invoice USING (trim(invoi… ^ HINT: No function matches the given name and argument types. You might need to add explicit

Advertisement