This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sql query regarding  RSS feed

 
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: 37180
515
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!