0

I tried adapting sql from here I must be doing something wrong (I know I am because I'm lost when it comes to SQL) Here's my sample table: I want the max ID with unique Trailer

|--ID--|Trailer|--To--|Load Qty A|Load Type/Config A|
|  1   | A100  |  B6  |     2    |        A1        |
|  2   | A100  |  A4  |     1    |        A1        |  <-Show this
|  3   | B099  |  B2  |     6    |        C23       |  <-Show this
|  4   | A027  |  N10 |     3    |        O1        |
|  5   | J400  |  A4  |     8    |        A1        |  <-Show this
|  6   | A027  |  A4  |     4    |        B24       |  <-Show this

I understand this is basically the same structure as the post linked above, but I really cannot get it to work. I thought that I had it working simply by having everything in the query as "last" except for trailer which I had "group by" but it started outputting incorrect records.

Community
  • 1
  • 1
Disk1of3
  • 1
  • 2
  • I figured it out. I created a query for just ID and trailer, set ID to Max and Trailer to GroupBy. Then I created another query with the rest of the fields and simply created a relationship between the ID fields. – Disk1of3 May 31 '14 at 05:27
  • If this closes the question for you, please add your comment as answer and accept it –  May 31 '14 at 11:13
  • I had to wait over 8 hours to answer my own question since I'm a new member. – Disk1of3 Jun 01 '14 at 01:46

1 Answers1

0

I figured it out. I created a query for just ID and trailer, set ID to Max and Trailer to GroupBy. Then I created another query with the rest of the fields and simply created a relationship between the ID fields.

Disk1of3
  • 1
  • 2