Wow Garry, I know that I like to kick-start my brain by getting 'into' a list problem/challenge in the (London) mornings, but today I'm completely beaten. Thanks for the broad explanation, which is probably quite meaningful, but I'm not into breeding (could that statement be misunderstood?) and so don't understand the terminology, but let's soldier on...
Can I request some db-speak please? You already have a tbl (or more). So let's start by asking for the table definitions Do you already have some SQL as a 'first attempt'? Could you also post that, together with a note about its short-comings/what needs to be added? That would also assist (my, feeble) comprehension. Usually in this sort of problem, the trick is to work out how to order/group the data, and then bearing in mind the various table-relationships, organise the join(s) and apply the requisite statistical functions. (that's the fun part) (if you haven't got anything started yet) Along with the definitions, how about starting a SELECT by listing the data you want to see, filling in the FROM clause, and then skipping to the WHERE clause and putting in the last or last-two criteria, eg the year/date-range to be used in the analysis - well do what you can/makes sense to you, so far. That might be enough to 'inspire' a solution - or start us on the way... Please advise, =dn > Hi All, > > I have a problem working out a suitable algorithm either in PHP or MySQL. > > Basically I have a DB that keeps track of breeding records. Each record > has a paired data, and a split-up date. > > I need to generate some statistics to work out average numbers of pairs > per month, averaged on a daily basis, for a given start and stop date, > typically a year or year-to-date. > > All the algorithms I can think of are messy, where I have to loop through > all the breeding records for every day of the year, and count how many > pairs are breeding by seeing if the date is between the start and stop > dates, and then average that on a monthly basis. I can't see > that scaling very well, as there might be several hundred breeding records > for a given year, multiplied by 365 days. > > Has anyone any hints/pointers for an efficient way to do this? > > Regards, > Garry. > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]