I want to surround the selected column entries with double quotes whenever there is a special character say ‘ | ‘ in the column value . In the above query in the true condition I want to surround email by double quotes whenever email contains | . For ex if email is a|bc@gmail.com , I want it to be “a|bc@gmail.com”.
Performance impact of view on aggregate function vs result set limiting
The problem Using PostgreSQL 13, I ran into a performance issue selecting the highest id from a view that joins two tables, depending on the select statement I execute. Here’s a sample setup: What I found out I’m executing two statements which result in completely different execution plans and runtimes. The following statement executes in less than 100ms. As far
Compare SQL Count
I want to return the name, which has not the con_id nr 2 and has more objects (count(*)) than in con_id nr 2. My statement isnt working because of the count.. can someone help me pls Select v.name …
How to sum 2 columns in a non-named table I have built from other tables
I have built a table taking columns from several other tables that are all linked by one or another common columns. I now need to perform simple multiplication on 2 the data in 2 columns contained in …
Creating NUMERIC array from JSONB data in Postgres
I have a Postgres JSONB data which contains an ARRAY of type NUMERIC. I want to extract this ARRAY and store it in a variable of type NUMERIC[]. Here’s is my JSONB object. { “userIds”: [ …
Remove special symbols from email string
I need to replace some characters in email string, exactly such actions: lower_email = str.lower(str.split(email,’@’)[0]) nopunc_email = re.sub(‘[!@#$%^&*()-=+.,]’, ‘ ‘, lower_email) nonum_email = …
SQL ORDER BY – how to honour same order as list in WHEN clause
A very basic SQL question I am forgetting. Given select * from customers where customer_id in (‘29383’, ‘49405’, ‘47483’, ‘10209’,’46383′, ‘93838’); …how can I order the results, such that it …
Postgresql on conflict update?
lets say i have table like this (new_table) (all field is not-null constraints): id name km_unit 1 honda 1000 2 toyota 2000 3 bmw 1000 4 wuling 1500 …
How to fetch and merge data according to groupby Mysql Php
I am working with mysql and php and i want to get data according to “city” in array Here is my table “merchants” merchantid localityId 1 30 …
SQL query to count rows based on condition? Keep getting syntax error for my count logic
So I want my query to return how many books total as a column, but how many books are returned as a column. I’m using count also applying a condition, but I’m getting error saying: Incorrect syntax near ‘)’. Anyway to achieve this? Answer Here is the syntax error count(bookstatus = R) You can convert it like below