# Filtered Parts 2 Analysis generated on: 4/2/2025 9:59:25 AM --- ## SQL Statement ```sql SELECT [Filtered Parts 1].PartNo AS PartNumber INTO [Filtered Parts] FROM [Filtered Parts 1] GROUP BY [Filtered Parts 1].PartNo; ``` ## Dependencies - [[Tables/Parts]] ## Parameters - *None* ## What it does **SQL Code Explanation** ========================== ### Overview The provided SQL code is used to group rows in a table based on the `PartNo` column and store the grouped data in a new table. ### Breakdown of the Code ```sql SELECT [Filtered Parts 1].PartNo AS PartNumber INTO [Filtered Parts] ``` * **SELECT Statement**: This statement is used to select specific columns from a database table. * `AS PartNumber`: This is an alias, which assigns a new name to the selected column. In this case, it renames the original `PartNo` column as `PartNumber`. * `INTO [Filtered Parts]`: This keyword specifies that the results of the query should be stored in a new table. ```sql FROM [Filtered Parts 1] ``` * **FROM Clause**: This clause specifies the table(s) from which data is to be retrieved. * `[Filtered Parts 1]`: This is the name of the original table being queried. ```sql GROUP BY [Filtered Parts 1].PartNo; ``` * **GROUP BY Statement**: This statement groups rows in a result set by one or more columns. The `GROUP BY` clause specifies which column(s) to group by. * `[Filtered Parts 1].PartNo`: In this case, the code groups the rows based on the values of the `PartNo` column from the original table. ### Result The final result is a new table named `[Filtered Parts]`, containing two columns: `PartNumber` and an implicit `ID` or row number. The `PartNumber` column contains the grouped values, which are the unique values in the `PartNo` column of the original table. **Example Use Case** Suppose you have a table `Parts` with columns `PartNo`, `Name`, and `Quantity`. You want to group all parts by their part number and store the result in a new table. The SQL code above achieves this: ```markdown +---------+-------+--------+ | PartNo | Name | Quantity| +---------+-------+--------+ | A | PartA | 10 | | B | PartB | 20 | | C | PartC | 30 | +---------+-------+--------+ Filtered Parts +------------+ | PartNumber | +------------+ | A | | B | | C | +------------+ ```