I have this table: date sku note 11/12 123 note 11/13 123 note 11/12 456 note 11/13 456 note 11/12 789 note 11/13 789 note (Note is random) And I want the result to return this: date sku note sku note sku note 11/12 123 note 456 note 789 note 11/13 123 note 456 note 789 note I tried self
Tag: mysql
Duplicate a row based in a column that has 2 values in spark sql
I have a temporary view that looks like this. What I want is to duplicate a row by adding an ‘All’ value to Activity Expecting result would be: I tried to create it through Zeppelin, but I am not able to update a view. Is there any way to do it please ? I can only use SQL unfortunately Thanks
SQL multiple left join as new columns performance
I have 3 tables : account id name 1 Google 2 Apple custom_field id name 1 Phone 2 Email custom_field_submission id custom_field_id entity_id value 1 1 1 555-444-333 2 1 2 111-111-111 3 2 1 google@goog.com 4 2 2 apple@apple.com Expected result after query id name Phone Email 1 Google 555-444-333 google@goog.co…
How to autofill a column with sequential number, but based on a parameter?
I’m trying to add a new column to few MySQL (MariaDB) tables. I want to make the column auto-filled with sequential number. What I figured out so far is: It works perfectly. However, I don’t know how to make it so that the order in which the numbers are assigned is based on another value, namely a…
subquery double where + aggreate functions
I have table and rows I want to have sum of balance and payed for simple users with approvedAdminId (isSimpleUser = 1 AND approvedAdminId is not NULL) and for not simple users (isSimpleUser = 0) Expected Result Answer Output:
Omit rows where multiple columns contain NULL
I’m trying to figure out how to build a query that omits rows where both columns of interest are NULL. If only one or the other is NULL, then I would like to include that data. In this example table, I would like to have a query that includes everything except row 3. My thought would be to build a
SQL query for all grouped records in joined table
Let’s consider a toy example. There is a table employees and table tasks, where each task is assigned to one employee. One employee can have multiple tasks. I want to query employees filtering them by some columns in their tasks. I group the employees to display each one only once. The query would be so…
Error in sql syntax value ? but it’s showing the value?
the title isn’t very specific but I don’t know how to make it better. I’ve got this error in my sql telling me something is wrong but I don’t understand why it’s wrong, currently using mysql 8.0.24. If you wonder why it looks strange it’s because I use it in lua Sql: Error:…
Trying to join two tables with multiple where condition on both table in sql
I wrote following sql query in where condition doesn’t affect the following condition What I did mistake here? Answer You can use the IN operator in the WHERE clause like below;
SQL group by return null if one is null
I have orders table that have delete marker column date_deleted which value is null or date order_number item_id date_deleted 111 aaa null 111 bbb null 111 ccc 2021-x-x I have query to select the fully deleted orders with group by order_number It give me this result order_number date_deleted 111 2021-x-x Whic…