|
|
Pull Table Columns based on Column Heading
I have a table PRDDTAY2K_OIVF040 that has forecast data in it. I want to create a query using specific columns from the table based on the column headings in the table. The column headings I need represents months (Current Month + 2). Is there anyway I can do this?
The following is the SQL view for the current query:
SELECT PRDDTAY2K_OIVF040.WKWH, PRDDTAY2K_OIVF040.WKPN, PRDDTAY2K_OIVF040.WKPCLS, PRDDTAY2K_OIVF040.WKPLIN, PRDDTAY2K_OIVF040.WKFJAN, PRDDTAY2K_OIVF040.WKFFEB, PRDDTAY2K_OIVF040.WKFMAR, PRDDTAY2K_OIVF040.WKFAPR, PRDDTAY2K_OIVF040.WKFMAY, PRDDTAY2K_OIVF040.WKFJUN, PRDDTAY2K_OIVF040.WKFJUL, PRDDTAY2K_OIVF040.WKFAUG, PRDDTAY2K_OIVF040.WKFSEP, PRDDTAY2K_OIVF040.WKFOCT, PRDDTAY2K_OIVF040.WKFNOV, PRDDTAY2K_OIVF040.WKFDEC, PRDDTAY2K_OIVF040.WKPRODWH, PRDDTAY2K_OIVF040.WKINACTIVE
FROM PRDDTAY2K_OIVF040
WHERE (((PRDDTAY2K_OIVF040.WKPCLS)="FC") AND ((PRDDTAY2K_OIVF040.WKPLIN)="AF" Or (PRDDTAY2K_OIVF040.WKPLIN)="AX" Or (PRDDTAY2K_OIVF040.WKPLIN)="AP" Or (PRDDTAY2K_OIVF040.WKPLIN)="PG") AND ((PRDDTAY2K_OIVF040.WKINACTIVE)"B"))
ORDER BY PRDDTAY2K_OIVF040.WKWH, PRDDTAY2K_OIVF040.WKPN;The following is what I would like it to do automatically:
SELECT PRDDTAY2K_OIVF040.WKWH, PRDDTAY2K_OIVF040.WKPN, PRDDTAY2K_OIVF040.WKPCLS, PRDDTAY2K_OIVF040.WKPLIN,
PRDDTAY2K_OIVF040.WKFJUL, PRDDTAY2K_OIVF040.WKFAUG, PRDDTAY2K_OIVF040.WKFSEP, PRDDTAY2K_OIVF040.WKPRODWH, PRDDTAY2K_OIVF040.WKINACTIVE
FROM PRDDTAY2K_OIVF040
WHERE (((PRDDTAY2K_OIVF040.WKPCLS)="FC") AND ((PRDDTAY2K_OIVF040.WKPLIN)="AF" Or (PRDDTAY2K_OIVF040.WKPLIN)="AX" Or (PRDDTAY2K_OIVF040.WKPLIN)="AP" Or (PRDDTAY2K_OIVF040.WKPLIN)="PG") AND ((PRDDTAY2K_OIVF040.WKINACTIVE)"B"))
ORDER BY PRDDTAY2K_OIVF040.WKWH, PRDDTAY2K_OIVF040.WKPN;
as you can see the query is now just getting the months of Jul, Aug, amp; Sep
PRDDTAY2K_OIVF040.WKFJUL, PRDDTAY2K_OIVF040.WKFAUG, PRDDTAY2K_OIVF040.WKFSEP
Any help would be appreciated.
Thanks,
Kurt
See this post for some suggestions on how to accomplish.
forum/showthread.php?t=319887
HTH,
CT |
|