Let's take a small table.
p q r
1 2 1
1 2 2
1 3 2
1 3 3
2 1 4
2 3 4
Q1: SELECT DISTINCT p,q FROM R ;
distinct will take both p,q together i.e first row is (1,2) is single unit now.
p q
1 2
1 3
2 1
2 3
Q2: SELECT p,q FROM R GROUP BY p,q ;
Grouping by both p,q i.e. p,q will be considered as a single unit for grouping.
Also notice output is only p,q columns in both query.
p q
1 2
1 3
2 1
2 3
Hence both query will have same results.
MORE: https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_distinct
try both query here.
Q1: SELECT DISTINCT OrderID,ProductID FROM OrderDetails
Q2: SELECT OrderID,ProductID FROM OrderDetails Group By OrderID,ProductID