I have a table #DEL_FAC where I need to select rows which have multiple entries. I used a partition function but I not able to figure out to weed out the rows which has only one single entry based on Rec_ID.
Below example will explain little better. So, from the output I would prefer to select REC_ID values which has multiple entries. In this example Rec_ID = 1052, 12811 and 1321 are the desired results.
I don't want to explicitly mention these Rec_ID in the WHERE clause since the table has hundred's of rows. This was just an example. Any help is highly appreciated. Thanks
SELECT
ID, NAME,
Rec_ID, CREATED,
ROW_NUMBER() OVER (PARTITION BY Rec_ID
ORDER BY (SELECT 01)) AS rn
FROM
#DEL_FAC
WHERE
CREATED = 'User_1';
Output:
ID Name Rec_ID Created RN
----------------------------------------------------------------
15755 MARBLE MFG 1032 User_1 1
17186 COMPRESSOR 1033 User_1 1
15711 Bakery Solutions 1052 User_1 1
15931 BAKERY SOLUTIONS - FROZEN 1052 User_1 2
16182 Ceramics Inc 128 User_1 1
16509 E-Z-G 12811 User_1 1
17836 E-Z-Go, Company 12811 User_1 2
15940 LANDFILL 1321 User_1 1
15182 LANDFILL- MAINT 1321 User_1 2
16291 Landfill -3 1321 User_1 3