I have a simple problem here using SQL views. I just can't seem to figure it out at the moment.
- I have 2 tables, TableA and TableB.
- I want to retrieve FieldA in TableA and FieldB in TableB.
- The two tables are linked using an INNER JOIN.
- I only want rows where TableA.FieldA are distinct.
- The returned values should be of the top 10 items from TableB.FieldB
Simply using SELECT DISTINCT seems to be using the combination of the two fields to determine distinction.
Any ideas?
Here is a mock of the SQL currently returning all rows :
SELECT dbo.TableA.FieldA, dbo.TableB.FieldB
FROM dbo.TableA INNER JOIN dbo.TableB ON dbo.TableA.ID = dbo.TableB.TableAID
An example of data returned from this standard query would be :
FieldA FieldB
John 78
John 21
Claire 18
Sam 16
John 25
Claire 48
Paul 53
What I am looking to have returned from the query would be :
John 78
Paul 53
Claire 48
Sam 16
Many thanks in advance.
**EDITED to try and make things a bit clearer and include missing information.