# Miscellaneous > Structured Query Language (SQL) >  Sql query to retrieve all rows with a unique column value

## ats00

Here is a sample of my expected result:

medical_thor_ref_num	transaction_id	rendering_provider_key
7390	1020658961_1_2_00081324100017	13450583002761700000000000463400000000
7290	1020658961_1_2_00081324100011	13450583002761700000000000463400000000
7240	1020658961_1_2_00081324100010	13450583002761700000000000463400000000
7340	1020658961_1_2_00081324100014	13450583002761700000000000463400000000
7490	1020658961_1_2_00081342040001	13450583002761700000000000463400000000
7040	1020658961_1_2_00081324100001	13450583002761700000000000463400000000
7640	1020658961_1_2_00081342040008	13450583002761700000000000463400000000
7540	1020658961_1_2_00081342040002	13450583002761700000000000463400000000
7440	1020658961_1_2_00081324100027	13450583002761700000000000463400000000
7190	1020658961_1_2_00081324100008	13450583002761700000000000463400000000
7140	1020658961_1_2_00081324100007	13450583002761700000000000463400000000
7090	1020658961_1_2_00081324100002	13450583002761700000000000463400000000
7590	1020658961_1_2_00081342040007	13450583002761700000000000463400000000


I need to retrieve all rows with the same rendering_provider_key. Your help is highly appreciated. Thanks

----------


## skhanal

Is it for one key? You can use 

SELECT * 
FROM table
WHERE rendering_provider_key=134505830027617000000000004  63400000000

----------


## ats00

> Is it for one key? You can use 
> 
> SELECT * 
> FROM table
> WHERE rendering_provider_key=134505830027617000000000004  63400000000


Thanks Skhanal but its not for just 1 key. That was just a sample of my expected results. I need all records grouped by the same rendering provider key.

----------


## skhanal

You can use 

SELECT <col1>, <col2>...
FROM table
GROUP BY rendering_provider_key

But you must use some grouping function like COUNT, MAX, MIN, SUM, AVG on all columns listed in SELECT list unless that column is part of GROUP BY list.

I am not exactly sure what your result set should look like, but even ORDER BY may work for you

SELECT * 
FROM table
ORDER BY rendering_provider_key

----------

