Hello people.
I have a table structured like this

+----------+-----------------------+
| Field    | Type                  |
+----------+-----------------------+
| dt_imp   | date                  |
| imp      | decimal(5,2)          |
+----------+-----------------------+

If I want to get the total per month I can do a query like this

        select date_format(a.dt_imp,'%Y/%m') "date",
                SUM(a.imp)
        from sp a
        group by date_format(a.dt_imp, '%Y/%m')
        order by 1

with a result like this

+---------+----------------+
| ...     |            ... |
| 2002/02 |         238.30 |
| 2002/03 |        1385.95 |
| 2002/04 |         475.30 |
| 2002/05 |         171.10 |
| ...     |            ... |
+---------+----------------+

now, I would like to get the avarage monthly import, so I could use the AVG() function.
Unfortunly I didn't understand how to use it in my case.
I've tried something like


select avg(subqry1) from sp

or

select * from subqry1

where suqry1 is the query precedently written; but I didn't succed in this.
How can I do to solve my problem?

thanks everybody.

G.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to