Skip to content

Tag: sql

How to concat all the entries of one column [SQL]

As the title states, with the following SQL query: I get the following result: Question: how to modify the query so that all the names are to be displayed in a row, so that they can be later used an array. What I tried: FOR XML, STUFF – doesn’t work Expected result: Answer If you are using SQL Ser…

SELECT rows with a new DISTINCT from a VARCHAR with CSV in it

I have an Oracle database table with a field called Classification which is VARCHAR. The VARCHAR is a CSV(using semi colons). Example: I want to pull all the rows with ONLY a different value in the CSV from the others. It is ok if a row has a previously found value as long as it has a new different value.

BigQuery SQL conditional IN

I have been trying to construct a conditional IN like below, but this gives me the scalar subquery produced more than one element error. How should I approach this type of query instead? The tables are not related. Answer Try this below- As your other tables are not related, you can try this below logic-

update a random row and get the row result back in MySQL

I have this table and an insert command is the following: The table contains random codes for each product_id. I want to get one unused code randomly (LIMIT 1 is ok for the job), mark the code as used and return it to the next layer. So far I did this: but this does not work well when multiple threads

Convert Postgre query to Hive/ Mysql

I have this table: I want to a situation where each footballer appears only once in a new table. For instance, Messi appears twice, but I want to take any occurrence of Messi in the new table. I am not sure how to convert it to either Hive or mysql. This is what I want the desired results to look