TABLEA
JobCode Job1 Job2 Job3 zip
------- ---- ---- ---- ----------
F F S NULL 90030
F F S NULL 90031
F F S NULL 90031
F F S NULL 90034
F F NULL 90034
F F S NULL 90034
F F S NULL 90034
F F NULL 90034
F F S NULL 90035
F F NULL 90035-4640
EXPECTED RESULTS:
JobCode Job1 Job2 Job3 zip
------- ---- ---- ---- ----------
F F S NULL 90034
F F NULL 90034
F F S NULL 90034
F F S NULL 90034
F F NULL 90034
F F S NULL 90031
F F S NULL 90031
F F S NULL 90030
F F S NULL 90035
F F NULL 90035-4640
Those with the SAME Zip should be ON top, then the rest follows. ORDER BY Zip does not work because it DOES sort by ZIP, and NOT by number of occurence
Using SQL Server 08