MySQL Forums
Forum List  »  Performance

Re: Get statistics using self joins
Posted by: Harutyun Drnoyan
Date: May 17, 2009 12:48PM

Hi.

Yes, I'll change it SMALLINT to TINYINT UNSIGNED, thanks.

Really I'm not using multiple tables for stats, but the same table is self joined for multiple time intervals to get multiple time interval data in one query (e.g view for 14.05.09-15.05.09, 15.05.09-16.05.09, 16.05.09-17.05.09 etc). This is why you can't see any reference to stats table but in where clause. As I posted early do not need any data from main table alias, just data from joined tables. stat1, stat2 ... are not real tables but aliases of joined tables (the same sample_stats table). I'm using distinct because multiple joins return multiplied value of rows - with not unique ids.

The subquery approach seems to be more elegant to get what I wanted. I'll give it a try ASAP. I'll post results here.

Thanks for your help.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Get statistics using self joins
2067
May 17, 2009 12:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.