<<
<!--
_filtered {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
_filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
_filtered {font-family:Garamond;panose-1:2 2 4 4 3 3 1 1 8 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;margin-bottom:.0001pt;font-size:11.0pt;font-family:"Calibri",
"sans-serif";}
a:link, span.MsoHyperlink
{color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
span.EmailStyle17
{font-family:"Calibri", "sans-serif";color:windowtext;}
.MsoChpDefault
{}
_filtered {margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
{}
-->
HELLO ALL: I have geophysical data that is measured each 10
cm down a drill hole. I want to apply a three point filter down the hole. That
is: for readings at 10, 20, 30 , 40, 50 cm etc I want to apply a formula that
incorporates the values at 10 , 20 & 30 cm for 20 cm; 20, 30 & 40 cm
for 30 cm etc. How do you do this. I understand how you would do this in excel
or in a vb array but I haven’t done anything like this in a
database. Is this where a cursor is used. Thanks for any hints. Joe DB
>>
Assuming that each measurement (10, 20, etc) is in a separate row in a table,
and assuming that each drill hole has an ID value that is consistent across all
depth measurements for that hole then yes, this is a classic instance in which
you'd use a cursor. EG:
HoldID Depth Measurement FilterValue
101 10 154
101 20 96
101 30 100
There are two different ways you could write the cursor -- either storing three
consecutive measurements as you traverse the table in code and then UPDATEing
the record one place "behind" the last measurement you're looking at, or else
using a SELECT INTO on each record to get the measurements before and after the
current record and UPDATEing the current record in the cursor.
If the number of measurements and the depth at which they were taken is
consistent for all holes, you could also create a denormalized view of the data
which would allow you to do the filtering with a series of update commands:
HoldID Depth10Measure Depth20Measure Depth30Measure
101 154 96 100
This is done by creating a view with a lot of IFEQ() functions and a GROUP BY
clause. It can be very advantageous for reporting purposes, but reliese on the
regularity of the data.
Finally, it's possible in standard SQL to write a SELECT statement that can get
the values before and after the row you're operating on, but it's a bit tricky
and I'm not sure that R:Base supports the full syntax. If you post the actual
structure of your table I'll see if I can come up with something. That would
let you update your filter values with one and only one SQL statement.
--
Larry