query database and return average of column to excel

A

Aster99

I'm using the following VB code to access my database.

ADO_rs.Source = "select ct_off_time,
least(2+(0.044117*CT_OFF_GEN),8)/count(*)as mydata2 from """ + "6b_NRatio" +
""".1

the above code produces something like this:

ct_off_time ct_off_gen mydata2
-------------------- ---------- --------------------------------
28-AUG-03 22:47:50.9 100.2 6.42008
23-OCT-02 14:39:23.2 0.34 2.015
03-JUL-02 21:39:36.9 -1.30 1.94265
31-AUG-02 18:28:14.2 -0.19 1.99162
24-JAN-03 11:46:17.2 41.42 3.82733
03-SEP-03 22:01:48.3 126.1 7.56359
23-JUN-03 06:21:54.6 14.81 2.65337
25-SEP-02 11:48:35.0 -0.19 1.99162
24-JAN-03 04:14:17.2 110.9 6.89434
29-AUG-03 00:00:50.9 -0.35 1.98456
--------------------------------
AVG 3.72842 <--- this is average of mydata2
column

now what I need to do is get the AVG (3.72842) and put it in excel.

ADO_rs.Open
ActiveCell.Offset(x, 5).Value = ADO_rs.Fields!AVG

How do I get the AVG into a variable so that I can send it to excel?
If I could just average the mydata2 column and store that value that would
work.

Any help is appreciated.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top