Query For Getting ID Degree

Jonny

Registered User.
Local time
Today, 23:02
Joined
Aug 12, 2005
Messages
144
Having a table DegreeDate
Fields are : ID, DegreeDate, Degree.

Each ID may have more than one degree.

Wish to build a query that shows only those whose degree is 50.
If same ID has higher degree he will not be shown.

Will appreciate your help..
 
Hi. Did you try putting a criteria of 50 under the Degree column?
 
Hi. Did you try putting a criteria of 50 under the Degree column?

Yes, but I want to get only those records where 50 is the higher degree.
If same ID has 60, 70, e.t.c not to show also 50.
 
Yes, but I want to get only those records where 50 is the higher degree.
If same ID has 60, 70, e.t.c not to show also 50.
I see. Maybe something like:
Code:
SELECT T1.* FROM TableName T1
INNER JOIN (SELECT T2.ID, Max(Degree) AS M
FROM TableName T2
GROUP BY T2.ID
HAVING Max(Degree)=50) SQ
ON T1.ID=SQ.ID
WHERE T1.Degree=50
 
This method will do it. It shows me the highest amount for a client, with the lowest value being £500. If higher, that is shown instead.

Code:
SELECT Transactions.Description, Max(Transactions.Amount) AS MaxOfAmount
FROM Transactions
GROUP BY Transactions.Description
HAVING (((Max(Transactions.Amount))>=500));
 
I'm a newbie in Access, may you add a screenshot how it looks in Access (not SQL).
Sorry for that..
 
I'm a newbie in Access, may you add a screenshot how it looks in Access (not SQL).
Sorry for that..
Instead, are you able to post a small copy of your db with test data?
 
I'm a newbie in Access, may you add a screenshot how it looks in Access (not SQL).
Sorry for that..

Ok, here it is

attachment.php
 

Attachments

  • Max Query.PNG
    Max Query.PNG
    11.7 KB · Views: 183
Last edited:
Instead, are you able to post a small copy of your db with test data?
Hereby please find attached,
Let's assume I'm putting "23" in Degree, then I don't want John to be shown as he has also 76.
Hoping it's clear..
 

Attachments

Hereby please find attached,
Let's assume I'm putting "23" in Degree, then I don't want John to be shown as he has also 76.
Hoping it's clear..
Hi. Thanks, but I am not sure I understand. Here's a screenshot of your data.

attachment.php


So, if we use 23 for a Degree criteria, which records should show up in the result? Everybody but John? Or no one?
 

Attachments

  • john.png
    john.png
    15.2 KB · Views: 205
Hi. Thanks, but I am not sure I understand. Here's a screenshot of your data.

attachment.php


So, if we use 23 for a Degree criteria, which records should show up in the result? Everybody but John? Or no one?

In this particular case nothing.
 
In this particular case nothing.
Okay, not sure it completely clarifies the ultimate intent, but I added a couple more records, since I want to make sure the query will return something acceptable other than nothing. Please let me know if this is anywhere close to what you want.


1. Open Table1 to review the two records I added
2. Open Query2 to see the result


If the result is correct for Degree of 23, then I think we can move on. If not, then please let us know why not and how else to move forward.


Thanks.
 

Attachments

Hereby please find attached,
Let's assume I'm putting "23" in Degree, then I don't want John to be shown as he has also 76.
Hoping it's clear..

Well my idea would not work,as it would show 76. :(

Sorry I misunderstood your initial post.
 
Consider:

SELECT Table1.*
FROM Table1
WHERE Table1.Degree=[enter value] AND FirstName NOT IN(SELECT FirstName FROM Table1 WHERE Degree>[enter value]);
 
Hi. Thanks, but I am not sure I understand. Here's a screenshot of your data.

attachment.php


So, if we use 23 for a Degree criteria, which records should show up in the result? Everybody but John? Or no one?

Okay, not sure it completely clarifies the ultimate intent, but I added a couple more records, since I want to make sure the query will return something acceptable other than nothing. Please let me know if this is anywhere close to what you want.


1. Open Table1 to review the two records I added
2. Open Query2 to see the result


If the result is correct for Degree of 23, then I think we can move on. If not, then please let us know why not and how else to move forward.


Thanks.

This one partially did the job, however when I put also DegreeDate column it shows me non-relevant record as well?!
 

Attachments

  • Capture.JPG
    Capture.JPG
    24 KB · Views: 61
  • 12222.JPG
    12222.JPG
    18 KB · Views: 73
Last edited:
I've marked DegreeDate as Max and it solved the issue.

Thank you, guys, for your help!
 
Hi. Why are you modifying Query1? Has the intent changed? I asked you to open Query2 and verify its result. What are you trying to accomplish by adding the date column in Query1?
 
Hi. Why are you modifying Query1? Has the intent changed? I asked you to open Query2 and verify its result. What are you trying to accomplish by adding the date column in Query1?
I took your solution , however when I was trying to add DegreeDate column the output was changed.
Apparently I was missing to add "Max" also to that column.
 

Users who are viewing this thread

Back
Top Bottom