Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL -- getting hourly averages of 15 minute bars
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01593485
Message ID:
01593536
Views:
36
>
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform