INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Don't select ID\Term\Class if has more than 1 record on a day & depends on the last record's rea

Don't select ID\Term\Class if has more than 1 record on a day & depends on the last record's rea

Don't select ID\Term\Class if has more than 1 record on a day & depends on the last record's rea

(OP)
Table example for just 1 ID but there are thousands and thousands of records:

ID TERM CLASSNBR REASON DATE TIME
1 1106 4444 Enrl 05/01/2010 11:00:00
1 1106 4444 Drop 05/01/2010 11:50:00

1 1106 4445 Enrl 05/01/2010 12:01:00
1 1106 4445 Drop 05/01/2010 12:11:00
1 1106 4445 Enrl 05/01/2010 20:50:00
1 1106 4445 Drop 05/01/2010 21:50:00

1 1106 5555 Enrl 05/01/2010 12:01:00
1 1106 5555 Drop 05/01/2010 12:11:00
1 1106 5555 Enrl 05/01/2010 20:50:00

1 1114 6666 Enrl 01/10/2011 17:00:00

Results wanted:

1 1106 5555 Enrl 05/01/2010 20:50:00
1 1114 6666 Enrl 01/10/2011 17:00:00

Don't want the other records because the last record for the day was Drop for ID\Term\Class.

Help is very appreciated!

RE: Don't select ID\Term\Class if has more than 1 record on a day & depends on the last record's rea

Hi

CODE --> MySQL

select
*

from kernal

where (classnbr, date, time) in (
    select
    classnbr, date, max(time)

    from kernal

    group by classnbr, date
)
and reason != 'Drop' 

Feherke.
feherke.github.io

RE: Don't select ID\Term\Class if has more than 1 record on a day & depends on the last record's rea

(OP)
Hey Feherke,

Thank you so much!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close