DISTINCTROW
DISTINCTROW is an SQL clause that is used to ensure that all the rows returned from a query are unique. It takes into account all the columns in the result set to eliminate duplicate rows. This clause is particularly useful in database scenarios where you need to streamline your dataset by removing redundancy.
Example
SELECT DISTINCTROW CityFROM Customers;Output
| City       ||------------|| Berlin     || London     || Madrid     || Paris      |Explanation
The above SQL statement is used to select distinct (different) cities from the “Customers” table. The DISTINCTROW keyword ensures that each row is unique for the column specified.
Example
SELECT DISTINCTROW Orders.OrderID, Orders.CustomerIDFROM OrdersOutput
OrderID   CustomerID--------- ----------1         ACME Corp2         Globex Inc3         Soylent Co4         Acme CorpExplanation
The DISTINCTROW keyword can be used in a SQL SELECT statement to omit duplicate records from the results. In this example, the SELECT statement returns a list of unique order IDs and associated customer IDs from the Orders table. Records where both the OrderID and CustomerID are identical to another record are excluded from these results.
Example
SELECT DISTINCTROW Student_ID, NameFROM StudentsOutput
Student_ID    Name------------- ------------1             John2             Joseph3             Martha4             Susan5             RonaldExplanation
The DISTINCTROW keyword in the SQL command is used to fetch distinct or unique records. In the example provided, DISTINCTROW is used to fetch unique Student_ID and Name from the table named Students. As a result, any duplicate rows with the same combination of Student_ID and Name are removed from the returned result set.
