• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql query regarding

 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly i am not an expert in SQL..

ok, if i want the recent log TIME on the recent DATE and corresponding data, i have a query like this:



I know the above query is very poor with many sub-queries.

What in your opinion would be the best way to handle such a query.. in the most optimized way? Your ideas please..

Thanks a bunch
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Antonio,
Presumbably the timelog table is large and contains data for many employees. So the first optimization is to only go through that table once. Also, make sure you have an index on empid.

For example:


Different database have different ways of saying to just return the first row. Alternatively, you could set the JDBC fetch size to 1.
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

wow, that's a clever way of getting what i wanted..

Thanks a bunch

I do have the table indexed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic