This might be impossible but I was wondering if someone more experienced knew if this is possible to do in postgresql. I have a column in my create statement CREATE table IF NOT EXISTS (other cols, …
Get totals from difference between rows
I have a table, with the following structure: ( id SERIAL PRIMARY KEY, user_id integer NOT NULL REFERENCES user(id) ON UPDATE CASCADE, status text NOT NULL, created_at timestamp with …
Getting first two unique records from two table joined – Mysql
Table 1: employee_detail: id name 1 ABC 2 CCC 3 FFF 4 ggg 5 jjj Table 2: performance_appraisal id …
Error 424 object required after NULL SQL query
I am running some EXCEL VBA code to update the contents of an ACCESS database table along the lines suggested here: IF @@Rowcount = 0 — SQL Syntax Error in Access . When I execute the SELECT query, …
How to SUM multiple DECODE values?
I have the following decodes in my SELECT case: DECODE (table_name, ‘RECHNUNG’, SUM(beleg_betrag_offen) ) as re_be_of, DECODE (table_name, ‘GUTSCHRIFT’, SUM(beleg_betrag_offen) ) as gs_be_of, DECODE (…
Replace text from VIEW Definition
I have the following VIEW definition: create view v_1 as select * from t1 where [date] between ‘2010-01-01’ and ‘2019-01-01’ union all select * from t2 where [date] between ‘2012-01-01’ and ‘2019-01-…
The reference constraint is being triggered but unable to select rows from the table that would trigger it
I am attempting to update a bunch of different tables in my database. However, when the update is completed, I am unable to delete a record from another table due to a foreign key constraint. However, …
How do I compare two SQL queries to run on Postgres
I need to compare two queries that will run in my Postgres database. How do I know the execution time and any other statistics of them so I can produce a reliable benchmark between them? Answer I can think of two interesting data points to collect and compare: The execution time. For that, simply execute the …
How to order a recordest returned from a query by a field created within that same query (MS ACCESS)
The Query (For this question I do not think that you need to see schema): SELECT Agencies.AgencyName, (SELECT DISTINCT MAX(Invoices.CostsTotal) FROM Invoices WHERE Contracts.ContractID = Invoices….
GetDate Function
I have a stored procedure that runs once a month for the whole previous year. So for example 5-1-18 to 5-1-19. I am going to create a job that fires it off at the first of each month. I need my stored …