1,214 questions
0 votes
2 answers
77 views
After updating a trigger in PostgreSQL, it updates all the records instead of specific records
I have a trigger to update a field when there is an update performed on a table. But the trigger updates all the records in the table instead of specific records. Trigger create or replace trigger ...
1 vote
1 answer
155 views
How to set replica identity full for a table having different owner?
I have two owners in my postgresql database e.g. testdb, I have some tables of owner1 and some tables of owner2. I am facing issue in setting replica identity full for tables of owner1 using owner2 ...
-1 votes
1 answer
32 views
Postgres query to find the data from a table where column type is json, using IN with list?
I am using postgres database, i am working with fastapi code where i want to find the data from database using the tags given. The tags column is json type and input will be the python list. I take ...
0 votes
1 answer
36 views
Removing leading comments from column data to categorize data
How can I extract an SQL query from a string that has leading comments and return the query along with any comments after the query, while ignoring any comments before the query. Example : Input: I) \...
0 votes
2 answers
958 views
How to calculate query result memory size in Postgres?
I'm creating a statistic reporting tool and facing an issue related to memory due to a high query result (application server not responding due to RAM is full). I can't restrict the query result by ...
0 votes
1 answer
161 views
I have to write an SQL query to find the 10th highest salary
I have created a table where I have given 10 entries of employee details as below: I used the below few queries to fetch the 10th highest salary of the employee: 1). SELECT * from ( select emp_id, ...
1 vote
3 answers
167 views
How to aggregate for first values in group
I have troubles creating certain aggregations. I'm using this table in Postgres: CREATE TABLE public.courier ( sender_app_type character varying(255), customer_id integer, from_id integer, to_id ...
1 vote
1 answer
366 views
How do i restart all of my sequences on PostgreSQL
I'm currently trying to figure out a way to restart all of my sequences (40 in total) to 2. But i don't have a single clue on how to do it. I have this command to change a single sequence back to 2, ...
0 votes
1 answer
44 views
PostgreSQL: get count of occurrences of array1 values in array2
I have a table: client_id order_id items_current_order items_next_order 905562 4254677 {1, 2, 4} {1} 905562 4254645 {1, 2, 5, 6} {1, 6} I need to count the proportion of items from the ...
-1 votes
1 answer
64 views
How to trim first '/' after filename in postgres
I need small help, Below is query through which I am fetching the data after filename and I am getting it but there is scenario where in some cases we don't have '/' after filename so I am planning to ...
0 votes
1 answer
119 views
Postgres sql to perform join
Just general question, can anyone pls help how to perform left join on union data. I have query where I am doing union of data(using table1 and table2) based on few conditions now I need to perform ...
1 vote
2 answers
77 views
How to remove duplicates and inc table records using postgres sql regex
I have created scenario in fiddle where I have to remove duplicate records and keep only 1 record example : for spotted table mfg_lz.icc_axbi_kanban_job there are 2 records so need to remove ...
0 votes
1 answer
77 views
Postgres sql with regex expression
Trying to run sql : https://dbfiddle.uk/VlKz_7fg When I am running sql on fiddle its working fine, however when I am trying to run the same on my database it is throwing - ERROR: invalid regular ...
1 vote
1 answer
231 views
Fetch table names using regexp
Need to fetch tablename from input using sql query.I know this can be done through regex but not sure how hence any help appreciated Input: Field1 field2 a INSERT INTO test.table2{ name, age, city, id}...
0 votes
0 answers
91 views
Postgres sort order results in different orders for different clients
Azure DB for Postgres flexible server I have Azure DB for Postgres flexible server. I have created a database in this server with en_US.utf8 collation. In this database I have created a table with ...