Compare records in a query

M

Martin Watts

Hi FOAK,

A database recording training course details. I have set up a query which
returns the learners ID and the level of each course they have completed as
represented below.

LEARNER ID LEVEL
6 1
6 1
8 1
8 2

I need to be able to 'compare' the records so that I can determine if the
learner has progressed. In the above example, learner 6 will not have
progressed as both courses completed were level 1, whereas learner 8 has
progressed has they have completed a level 1 course and them completed a
level 2 course.

How would you do it?

TIA

Martin Watts
 
J

John Spencer (MVP)

On the limited set of data you gave you could use min and max and group by.

SELECT [Learner ID],
IIF(Min(Level)=Max(Level),"No Advance","Advance") as Status
FROM YourTable
GROUP BY [Learner Id]

However, I assume the problem and the data is more complex than what you gave as
an example.
 

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

Similar Threads

Urgent - How to using formula to compare 2 worksheets 3
dynamic calculated field in query 3
Count 8
Filter out records with earlier dates 1
Query Help 4
Compare Records 1
Inverted Query 2
Double data in Query 1

Top