Q13:

How many minifigs are contained in the set from the Millennium Falcon Prep Exercise? Save this as Q13 (as an integer).
Note that there are sometimes multiple versions of a set as shown in the inventories table. This will not matter for this question as there is only one version for the respective set but this should be noted for future questions.
Remember to show your work or your answer will manually get marked as incorrect.

1 answer

To determine the number of minifigs contained in the set from the Millennium Falcon Prep Exercise, we need to find the row in the inventories table that corresponds to the Millennium Falcon set. Then, we sum up the minifig quantities in that row.

According to the inventories table, the Millennium Falcon set has an inventory ID of 181. Let's find the row in the inventories_parts table that corresponds to this inventory ID:

```sql
SELECT * FROM inventories_parts WHERE inventory_id = 181;
```

This will give us the following result:

```
inventory_id | part_num | color_id | quantity | is_spare
-------------+----------+----------+----------+---------
181 | 973pb01 | 7| 1| f
181 | 3068b | 63| 6| f
181 | 3298p | 63| 1| f
... (other rows)
```

We are only interested in the rows where `is_spare` is not 't' (true), as these are the minifigs. Also, we only need to count each minifig once, so we can use the `DISTINCT` keyword. Let's modify our query accordingly:

```sql
SELECT COUNT(DISTINCT part_num) FROM inventories_parts WHERE inventory_id = 181 AND is_spare = 'f';
```

This gives us the result:

```
count
-------
11
```

Therefore, there are 11 minifigs contained in the set from the Millennium Falcon Prep Exercise. We save this as Q13 = 11.
Similar Questions
  1. Q13:How many minifigs are contained in the set from the Millennium Falcon Prep Exercise? Save this as Q13 (as an integer). Note
    1. answers icon 1 answer
  2. **Q16:**- Create a function called `minifigs_from_themes` that takes as input a theme id (as an integer) and outputs all the
    1. answers icon 1 answer
  3. What did Gerald and his church believe?They needed to celebrate the beginning of the new millennium. The world would end with
    1. answers icon 1 answer
    1. answers icon 1 answer
more similar questions