MSSQL Distinct, help
Posted on 2010-09-16
I have an issue I have 2 tables with about 20,000 rows in. It contains name, email pins etc. Below see my SQL to retrieve all of the data.
What I need is a way of DISTINCTLY selecting the results but take the one with the highest X_ID.
SELECT x_id, name, email, primarypin
FROM cas_user_ext, cat_validation
WHERE cas_user_ext.x_id = cat_validation.id
This will return for example.
X_ID, name, email, primarypin
11, SChurch, SChurch@dsa.com, 115545544
12, SChurch, Schurch@dsa.com, 151516165
I would like to select the result with ID 12.