I’ve been trying to figure this one out for days but can’t come up with a solution. Here are the table schemes. This is my current query. The problem is that the query returns as long as there is one article with status bigger than 1. I need a query where all the articles of that order have a stat…
Select based on multiple ID’s in the same column
I have two SQL tables already built (not by me) : One table that has all the ingredients with ID’s assigned to them : and the second table that has finished products that have reference to ingredientID in the ProductIngredients column but no the product name and they are built like this : If they don…
sql query for grouping column into row
So, I have table like this and I want to make query so the result is like or I have try to use GROUP BY but I dont know how to get the slot number. Please help, thank you! Answer With conditional aggregation: See the demo. Results: And for the 2nd case use group_concat(): See the demo. Results:
Need Combined SQL Query to Update 2 Tables
I am having 2 tables. Table1 and Table2. I need to update these 2 tables based on some conditions. The SQL select query from Table1 will return multiple records, let’s name it as SQLQuery1 From SQLQuery1 results returned I need to loop through each record and execute another SQL query from Table2 which …
How to find how many times X appears
Learning SQL using SSMS and I have been given a database and a 32 questions. I am working my way through the questions and got suck on a question of “How many people live in each city?” I know how to …
Delete rows where string value appears inside another row value that is larger
I am trying to make a table smaller by removing values that appear inside other larger values. e.g. Column Row1 potato234 Row2 to2 Row3 ot Row4 potatos The outcome I want is for row 2 and 3 to …
How to create sql db2 data table using python?
I would like to run an sql db2 query on python that will create a data table in a public schema but I’m stuck because of this error ResourceClosedError: This result object does not return rows. It …
SQL Server query duplicating rows based on inventory locations that have been claused out
My current code is duplicating results per item_id. I am summing the previous three months usage per item in two locations. I do have more locations but I limited it in the WHERE clause. I think the …
how do i group rows by an id row in group_concat into one row string?
i have table like this | col1 | col2 | col3 | | a | 1 | g1 | | b | 2 | g1 | | c | 3 | g1 | | d | 4 | g2 | | e | 5 | g2 | | …
How to COUNT “accounts” only if character/user exist
I have 2 tables – “accounts” and “players” I’m using this query to COUNT accounts Accounts table estructure: Players table estructure: * Let’s say the query counts 10 accounts but only 3 accounts have a character/user created. I would like to know how to count only th…