This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

incorrect MAX result with query. (diagram photo included)

 
Peter Primrose
Ranch Hand
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have the following SQL statement that returns the table-photo below:




I would like to get the *latest* note from each entity_id from the table (the resulted query).
For this I did:



but the results are incorrect. the max(note_date) is correct but not the note?!?!?!
any idea what am I doing wrong?

thanks

 
Scott Selikoff
author
Saloon Keeper
Posts: 3894
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All records in a query result set must be uniform in type. Therefore, your combination "SELECT MAX(note_date),..." will not work since it should return the max note date and all records joined with in. If you want a single record you need to indicate that such as "select record where note_date = (select max(note_date))".
 
Peter Primrose
Ranch Hand
Posts: 755
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep....thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic