0

So I work for a university and I'm trying to get our enrollment process correct for our learning management system for students who add and drop classes. The problem I'm experiencing is when a student drops a particular class and then re-adds the same class the ERP system we use inserts a row for each add and drop. So the student originally adds the class say on 3/2 but then drops the later class on 3/2, this is one row. Now the student needs to add that same class back, this would be another row. Here is a quick sample I hope makes sense. I'm trying to figure out the SQL syntax to accomplish this.

id   year   term   seqNum   course       add_date                       drop_date
21   1920   SP      5        PM510-50   2020-03-02 19:31:19.000       2020-03-02 19:35:48.000
21   1920   SP      8        PM510-50   2020-03-02 19:38:19.000       NULL  
Serkan Arslan
  • 13,158
  • 4
  • 29
  • 44
JasonB
  • 21
  • 2
  • 1
    Can yo please elaborate a little? Exaclty what are you trying to accomplish and what results are you getting now? – AAM Mar 23 '20 at 19:56
  • 1
    Welcome to Stack Overflow. To help us help you, please take the [Tour](https://stackoverflow.com/tour) and read through [How To Ask](https://stackoverflow.com/help/how-to-ask). Take a look at this [well-structured question](https://stackoverflow.com/questions/60453346/use-or-conditions-in-where-clause-as-column-names-in-result), then [edit](https://stackoverflow.com/posts/60820540/edit) your question with the details needed to create [a Minimal, Complete, and Verifiable Example for database-related questions](https://dba.stackexchange.com/help/minimal-reproducible-example). – Eric Brandt Mar 23 '20 at 21:01
  • 1
    Well, a much easier approach would be to use ROW_NUMBER if you just want to show the last row. PARTION BY id, Year, Term, Course – Robert Sievers Mar 24 '20 at 13:57

0 Answers0