is the a funtion of code syntax to grab only records with a particular data field record.
for example permit Numbe 246172 is the same but I only want the typeno '2' record only
is the a funtion of code syntax to grab only records with a particular data field record.
for example permit Numbe 246172 is the same but I only want the typeno '2' record only
So your desired output would be
Ctr-246172 with TypeNo 2
and
Ctr-234280 with TypeNo 1
So you only want the greatest TypeNo per individual permit?
For that you would want to use ROW_NUMBER() and a CTE to then filter on the maximum typeno
;WITH CTE AS ( SELECT permit_number, subdivcol, typeno, ROW_NUMBER() OVER (PARTITION BY permit_number ORDER BY typeno DESC) AS RN FROM <yourtable> ) SELECT permit_number, subdivcol, typeno FROM CTE WHERE RN = 1
17 People are following this question.