I am trying to run the below query to get a substring from a string but it gives wrong result. I am not sure how to use the regex since the regex I am using works well with PCRE. I am expecting to get ndehqb-a3g4-a10 in this case but it prints the original string itself. The ask is to get
Tag: sql
How to solve impala insert with select query error?
i want to insert a row to service_log table with max+1 id value. But this gives me the following error ; How can i solve this problem? Answer This should work with most SQL dialects:
Get last and first record using rank()
I need to get first and last record (ordered by Date column) from table for certain SSID. It is not a problem if there is more records with same max or min date. All I need is union all. I am getting last record having max(date) with: How to I get first record (min(Date)) as well (same thing only with
How to pass table name as a parameter in update procedure in Oracle?
I am new to Oracle so please sorry the question that seems to be very easy for you. I need to get the following procedure with UPDATE query with replace function This procedure removes all spaces. But when I call it I’ve got the following error How can I modify my code to handle the problems? Thank you.…
How to classify rows having one or more related records
I need to add the additional column called rank_2 which will show whether the source has more than 1 source_ids. So, I need to get this result: I don’t know how to write a query to get rank_2, which will contain 1 when the source has the only source_id (like the source “b”) and contain 2 whe…
loosing connection to sql server from express js api
Im building this api that gets data from a database and posts data to another database both located on the same server but it seems that im having problems with the connections when i first run the app everything works fine but after making some api calls it just crashes and doesnt work again my guess is conn…
Select the row with the most recent modified date
I have this table: user_id name email modified_date 1 John a@gmail.com 2022-01-01 1 John b@gmail.com 2022-01-02 1 Lucy c@gmail.com 2022-01-03 2 Joey d@gmail.com 2021-12-24 3 Mike e@gmail.com 2022-01-01 3 Mary f@gmail.com 2022-01-02 I’m trying to get unique user_id’s email with the most recent modi…
Find the difference between 1 column depending on date
When I run this: I see 62 rows but when I do I see 59 I want to see what NAME’s are missing when it ran for _LOAD_DATETIME::date = ‘2022-02-01’ I thought this would work but it doesn’t: Answer You have to use MINUS for your purposes: If we are talking about PostgreSQL, you have to use …
When you give a table a name are you temporarily cloning it? (MySQL)
It’s a common question: Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Example 1: Input: Person table: Output: I know that to select what I don’t want, I have to do something like this: After that portion I got stuck, so I looked at the a…
How to convert Buffer to base64 image in Node js
I am getting data from my SQL database like this: How can I convert result to a base64 image in Node.js? For Example: ‘data:image/png;base64,iVBORw0KGgoAAAANS’ Answer Since you’re receiving a Buffer back as output, Buffer.toString(‘base64’) will convert the raw binary data in the buffe…