I have a column in my SQL database (using mySQL) ‘lastname’, which has any number of employee’s last names in it. I want to write a query that handles a search for last names using a comma delimited list. So the user will type: And that gets stored in a String, lastNameQuery, which then gets passed into my backend API
How to resolve subquery return more than one value in oracle
Could somebody please help me how to achieve the following? Table: My output should look like Thanks Inadvance. Answer We can use conditional aggregation with the help of ROW_NUMBER(): To create a view, use:
PSQL stored procedures using arrays as parameter
I’m using PostgreSQL and currently creating a stored procedure to do some calculations. I’ve been searching all morning and reading the documentation, but either the functionality I want isn’t supported or I must’ve overlooked something. Basically, this is what I have: Basically what happens is that I calculate how often I need to make a travel to deliver something, which
How can I combine two columns and sort the values alphabetically?
I’m new to programming languages and am trying to get the customers with the longest and shortest names, combine them in a single column, and sort them by longest then shortest names. Here’s what I have. How can I query to get my desired result in MySQL? Table is orders customer_id longest lowest John Nathaniel John Michael Nathaniel Expected results
Is it possible to further filter on MAX results?
I have a table like so A) As you can see, the same ID can have multiple Revision IDs Now, I can grab all the latest revision for each ID by using MAX with GROUP BY like so: B) As you can see here, the Revision ID of 47141 is the latest revision for ID 3282 So here is my
Speed up removal of duplicates in Oracle with indexing
How to remove duplicate entries from a large Oracle table (200M rows, 20 columns)? The below query from 2014 is slow. It took 2 minutes to delete 1 duplicate entry for one specific combination of columns (i.e. where col1 = 1 and .. col20 = ‘Z’). Any way to speed it up, e.g. with indexing? Answer Rather than using an
Passing tuples to SQL query while unnesting
I need to query a large BigQuery table to retrieve data from certain dates about barcodes in a store. There is a specified date for each of these barcodes (there are thousands of dates for each barcode in the BigQuery table, which makes it unpractical to only query on barcode). I have therefore created a list of tuples containing the
How to create a function that returns a value if id is in an array?
I’m trying to create a new function in supabase. I’m quit new to SQL and postgreSQL so I’m not sure what I’m doing. Anyway I want to make a function that checks if one value is in an array of ints. If it is then return 0.8 if it’s not then return 1.0. Here is my code I get the
Lost connection to MySQL server during query error when I try to use function
I am trying to make a function which checks if any date between say Date-range A and B lies between the Date-range C and D. Whenever I try running the function MySQL Workbench always throws an Error Code:2013 Lost connection to MySQL Server during query. I am assuming this error is arising due to the loop running forever (please correct
How do I auto-increment a alphanumeric string primary key?
Let’s say I have table A with an alphanumeric string primary key. The code used to create the table and how the table looks are shown below. I want to insert a new row into Table A and I don’t want to type out C000003 or C000004 every time. Is there a way to auto increment this? I have thought