# Database Discussions > Microsoft SQL Server 2008 >  Sql query to retrieve rows grouped by specific values in a column

## ats00

Hi, 
    I have been battling with this query for a while now. I attached a snippet of the raw file (claim) and also a sample of the expected results. The rule looks for claim lines that meet the following criteria:
	PATIENT_KEY is the same
	RENDERING_PROVIDER_KEY is the same
and CPT_HCPS_PROC_CD must have at least all 8 codes (82330, 82374,84520,84295, 84132,82947,82565,82435). Duplicates don't matter.


Any help is appreciated ! 


Thanks
ATS

----------

