Skip to content
Advertisement

How to find and replace string using REGEXP_REPLACE in postgresql

I have a table of email addresses: How can I find and replace the email format so example.person@gmail.com -> example.person_gmailcom@test.com? E.g: Results in example.person@test.comgmail.com Playground here: https://dbfiddle.uk/GnIfomiO Answer This is probably most simply done by splitting the email address in two on the @, keeping the part before it and replacing . in the part after it with nothing. Then

Oracle chr() diferent returns from SQL engine versus PL/SQL engine, why?

Same function, same argument, different outputs: PL/SQL procedure successfully completed. Answer In your case, chr() appears to be performing an implicit conversion to binary_float (IEEE 754 floating-point representation) as the datatype, as opposed to number (ANSI SQL NUMERIC). This results in different rounding results. I cannot duplicate your results on 19c unless I force the datatype, in which case I

Calculate number of watches by number of users in sql

I want to write 1 query that calculates the frequency buckets for each Ad. The frequency buckets would be the number of users who watched the Ad 1 time, 2 times, 3 times, etc. The table is: AdId UserID Watch Date 123 A 1/22 123 B 1/13 123 C 1/22 123 A 1/24 123 A 1/11 123 B 1/10 123

How to split an XML string into parts with different keys

from XML column I wanna try get info. Every client have more that one contract_key in XML, im using split_part and strpos for get needed information : But problem is this function return the first match found: ID Key amountR AVGamount 2253545 1 10000 50 this client in same XML have more Contract_key: ID Key amountR AVGamount 2253545 5 70000

String length mismatch not giving data in another column

I’ve a column location in my table. I’ve used it as a common column to join two tables 1.Factory 2.Inventory Like Factory.location = inventory.location But I’m having a problem.. For example Location in factory table just has 09 where inventory table has 009 doesn’t match but for three digit numbers it’s matching eg: 115 = 115, 999=999. But in the

SQL with grouping sets returns the initial table

I have a sample table like this: name manager country position salary Mike Mark USA Content Writer 40000 Kate Mark France SEO Specialist 12000 John Caroline USA Outreach Expert 32000 Alice Caroline Italy SEO Specialist 50000 Philip Caroline Italy Marketing Manager 30000 Julia Caroline Italy SEO Specialist 44000 I’m writing a query to get the avg. salary from the table

Advertisement