Need assistance to write a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top