Skip to content
Advertisement

SQL query – fill missing value

I have a table:

I have three parts with id (1,2,3) and these parts are of any type in different places. However, on the place, “70” hasn’t written type. However, as part of piece counting, I need to count for location 70 for a given type (for example, X5). But the one in place 70 is not listed. How can I add this data in my selection within a subquery? For example, I take those ids and somehow refer that those ids are of type X5?

I want:

SQL query to select all columns for location 70 with the type added for the given id.

I tried this sql query, but it is wrong:

Advertisement

Answer

I found part of answer to your question here:

my demo (I made it here):

returns

MySQL solution (demo):

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement