>
>select account, mHour, MAX(mRating) as MAxRating FROM Ratings GROUP BY account, mHour, mRating
>
>
>gives me losts of results -- presumable the max of the 15 minutes ratings in any given hour.
>But--without writing a whole program--can I use SQL to show each account's
>maximum rating in a given year or a given month.
>Thank you again.
Steve,
SQL can do this and lots of other things.
To show max rating for account for a given year:
select account, max(mRating) as MaxRating, mYear from Ratings WHERE mYear = ?m.pnYear GROUP by account, mYear
pnYear will be a year parameter
If you want maximum rating for a given month, I assume it's for a given month of a given year, not just across all months in the table?
If the former, then
select account, max(mRating) as MaxRating, mYear, mMonth from Ratings WHERE mYear = ?m.pnYear AND mMonth = ?m.pnMonth GROUP by account, mYear, mMonth
where pnYear and pnMonth your parameters.
If it's not broken, fix it until it is.
My Blog