# Google Sheets Query: How to Return Only Unique Rows

You can use the following basic syntax to return only unique rows when performing a query in Google Sheets:

`=UNIQUE(QUERY(A1:B16, "SELECT A, B"))`

By wrapping the UNIQUE() function around the QUERY() function, we can return only the unique rows from the query.

The following examples show how to use this syntax in practice.

### Example: Return Unique Rows in Google Sheets Query

Suppose we have the following dataset that contains information for 15 basketball players: We can use the following formula to perform a query that returns only the unique combinations of Team and Position:

`=UNIQUE(QUERY(A1:B16, "SELECT A, B"))`

The following screenshot shows how to use this formula in practice: Notice that the query only returns unique combinations of Team and Position.

For example, there are three rows where Team is equal to “A” and Position is equal to “Guard” but only one of these rows is returned in our query.

We can also wrap the UNIQUE() function around more advanced queries.

For example, we could use the following query to return only unique rows where the team is equal to A or B:

`=UNIQUE(QUERY(A1:B16, "SELECT A, B WHERE A='A' OR A='B'"))`

The following screenshot shows how to use this formula in practice: Once again, the query only returns unique rows.