Need assistance to write a query

M

Mike

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.
 
K

Ken Sheridan

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
 
J

Jeff L

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!
 
Top