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 ̵…
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 Design and Query a Table for storing Combinations
I was looking to store combinations of two fields (not permutations – order does not matter). For example, lets say I have two integer fields: A and B. I want to store the combination (1, 2). Meaning …
MS Access SQL: Sum IIF for multiple Criteria, Format as Column instead of Row
I’m working in MS Access 365 and I have a table containing multiple status that I want to summarize in a Pie Chart. Sample Data: Sales Order# Status 1 New 2 Pending 3 Closed The Statuses are defined by human readable text in a separate table, but are linked in the master table before I run the query. I …
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-…
SQL – Sum of specific column grouped by a specific value of another column
I have a SQL with list of Customer IDs and invoices, the specific product purchased in each invoice, and the income of each invoice. I need to write a query that will result in a list of customer IDs in one column, and the sum of total income from purchasing “product A”, by each customer, in anoth…
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 …