Hi All

I am a fresher in this company but faced with the great challenge of constructing a complex query with no Programming to be done...

Your help would really help and benefit in enhahcing my learning curve.

For all records within the last 10 days, from vtable's CREATEDDATE column update all the vtable records with a metric value derived from the APTABLE ,when a match is based on the persons [MARKET, CUSTOMERTYPE, EVENTDATE and FIGURE].

When applying the metric values it must first check what Figure the person was assigned to during the evntdt and apply the correct metric value using the histtable table

Logic expanded further:

For a person pick up only those evntdts which are for last 10 days from the created date in vtable
Then from the obtained list of eventdts check with histtable which evntdte/s falls between the from and to date and then pick up the associated figureID/s for that date range
Now using this figureids pickup the required values from metric column present in aptable but again based on the rule of last 10 days from created date


Table Names :
aptable
vtable
histtable

Table Fields
Aptable:

market
marketid
metric
custtypeid
Figure
AP_Val


vtable:
person
marketid
evntdt
custtypeid
createddate


histtable:
person
figure
figure_id
from_dt
to_dt