Thanks will try this
Had also tried this but is falling over
SELECT
ststats.company,
ststats.depot,
ststats.part,
ststats.sale_period,
ststats.sale_year,
ststats.units,
"CurrentPeriod".notes,
"CurrentPeriod".code_value::smallint AS "CurrentPeriod",
"CurrentYear".notes,
"CurrentYear".code_value::smallint AS "CurrentYear"
FROM
public.ststats,
public."CurrentPeriod",
public."CurrentYear"
WHERE
ststats.company = "CurrentPeriod".company AND
ststats.company = "CurrentYear".company AND
ststats.sale_year >= '2011' AND
public.CurrentPeriod.code_value = sale_period -1
With this error - where I am going wrong?
ERROR: missing FROM-clause entry for table "currentperiod"
LINE 20: public.CurrentPeriod.code_value = sale_period -1