Let’s assume after merging few tables I have the following t1 query with 2
columns
(pk and number)
PK numbers
1 5
1 6
1 7
2 9
2 50
2 60
3 40
3 44
I would like to write a query that gives me the first rows that the
t1.number is minimum when the t1.pk is the same. The output should look like
the following:
1 5
2 9
3 40
Any help is greatly appreciated.
Ken Sheridan - 19 Jul 2006 18:52 GMT
Group by the PK column and use the MIN function to return the lowest Numbers
value for each PK:
SELECT PK, MIN(Numbers) AS MinNumber
FROM T1
GROUP BY PK;
Ken Sheridan
Stafford, England
> Let’s assume after merging few tables I have the following t1 query with 2
> columns
[quoted text clipped - 19 lines]
>
> Any help is greatly appreciated.
Jeff L - 19 Jul 2006 18:59 GMT
Make a query that outputs PK and Numbers. Now click View, Totals or
click the Totals icon in the toolbar. For PK, the Total row should be
Group By and for Number it should be Min.
Hope that helps!