Skip to content

User Permissions error for reading from view in postgres

I am using postgres and have a new read-only user that has read permissions on all tables in a base schema. I was trying to SELECT some data from a particular view from base schema and was able to see the values from the view. To test the data count I had to make some changes in the view definition

SQL Use Value from different column on same Select

I have a question if this is possible which will save me time writing extra code and limits user error. I need to use a value from a column (which has already performed some calulcation) from the same select then do extra calculation on it. I encounter this a lot in my job. I will highlight the problem with a

Check if all values in a column falls into a specific group

I have the following table: and I want to check ALL values of the column ‘Token’ and return a flag string to designate what condition is met: when all records are in group (A, B) –> return ‘Condition1’, examples: when all records are in group (A, B, C) –> return &#821…

SQL Query – second ID of a list ordered by date and ID

I have a SQL database with a list of Customer IDs CustomerID and invoices, the specific product purchased in each invoice ProductID, the Date and the Income of each invoice . I need to write a query that will retrieve for each product, which was the second customer who made a purchase How do I do that? EDIT: …

SQL Get all Saturdays between two Dates

I’m trying to find all the saturdays between two dates (inclusive) without using a loop. For example, April 1, 2021, to May 1, 2021 should return: 04-03-2021 04-10-2021 04-17-2021 04-24-2021 05-01-…

How to delete last row using SQLAlchemy?

I need to exec next query: DELETE FROM
ORDER BY DESC LIMIT 1 I trying: query = session.query(MyTable) query.order_by(MyTable.my_column.desc()).limit(1).delete() …

Oracle Object-Relational – PLS-00122 error

Type declaration: CREATE TYPE INTERVENTO_TY AS OBJECT( Testo VARCHAR2(20), Timestmp DATE ) NOT FINAL; CREATE TYPE COMMENTO_TY UNDER INTERVENTO_TY( Ordine VARCHAR2(20) ); CREATE TYPE POST_TY …