Hi Feherke
This is my Query for pulling information out
select
oid as recid,
fk_oid as patientid,
DIDAT as date,
prepost,
DIWT as weight,
DIBPS, DIBPD, DIGAIN, DIIW, DIHEIGHT, sp_bmi(oid) as BMI
from p_anthropometry
where fk_oid = '3'
order by fk_oid, didat desc
this gives me
recid ,fk_oid, date , Prepost , weight
'188856', '3', '1982-02-26 00:00:00', '200100', '71.8', '150', '60', NULL, NULL, NULL, NULL
'188855', '3', '1982-02-26 00:00:00', '200101', '69.3', '120', '60', NULL, NULL, NULL, NULL
'188858', '3', '1982-02-24 00:00:00', '200100', '72.3', '145', '65', NULL, NULL, NULL, NULL
'188857', '3', '1982-02-24 00:00:00', '200101', '70.5', '120', '60', NULL, NULL, NULL, NULL
'188859', '3', '1982-02-22 00:00:00', '200101', '71.1', '120', '60', NULL, NULL, NULL, NULL
'188860', '3', '1982-02-22 00:00:00', '200100', '73.3', '145', '60', NULL, NULL, NULL, NULL
'188862', '3', '1982-02-19 00:00:00', '200100', '73.4', '150', '60', NULL, NULL, NULL, NULL
'188861', '3', '1982-02-19 00:00:00', '200101', '71.3', '120', '60', NULL, NULL, NULL, NULL
'188864', '3', '1982-02-17 00:00:00', '200100', '73.5', '160', '60', NULL, NULL, NULL, NULL
'188863', '3', '1982-02-17 00:00:00', '200101', '72.1', '125', '60', NULL, NULL, NULL, NULL
'188866', '3', '1982-02-15 00:00:00', '200100', '74', '150', '60', NULL, NULL, NULL, NULL
'188865', '3', '1982-02-15 00:00:00', '200101', '71.8', '125', '60', NULL, NULL, NULL, NULL
'188868', '3', '1982-02-12 00:00:00', '200100', '74', '165', '60', NULL, NULL, NULL, NULL
'188867', '3', '1982-02-12 00:00:00', '200101', '71.8', '125', '60', NULL, NULL, NULL, NULL
'188870', '3', '1982-02-10 00:00:00', '200100', '74.2', '150', '60', NULL, NULL, NULL, NULL
'188869', '3', '1982-02-10 00:00:00', '200101', '72.3', '120', '60', NULL, NULL, NULL, NULL
'188872', '3', '1982-02-08 00:00:00', '200100', '75', '155', '60', NULL, NULL, NULL, NULL
'188871', '3', '1982-02-08 00:00:00', '200101', '73', '125', '60', NULL, NULL, NULL, NULL
'188874', '3', '1982-02-05 00:00:00', '200100', '75', '155', '60', NULL, NULL, NULL, NULL
'188873', '3', '1982-02-05 00:00:00', '200101', '73.5', '130', '60', NULL, NULL, NULL, NULL
'188876', '3', '1981-12-16 00:00:00', '200100', '74', '165', '60', NULL, NULL, NULL, NULL
'188875', '3', '1981-12-16 00:00:00', '200101', '72.8', '130', '60', NULL, NULL, NULL, NULL
200100 = 'Pre'
200101 = 'Post'
I need to show the following
'Date' 'Preweight' ' Last Post weight before preweight i.e before preday' 'difference between preweight and last post weight' 'Interval between Prewieght and last post weight dates'
so it looks like this
Date PreWt lastpostwt IDFG Interval
08/02/2012 101.6 100.0 1.6 2 days
06/02/2012 100.3 100.3 1.2 3 days
01/02/2012 101.4 99.8 1.6 2 days
to show last 6