Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting/Filtering from "Previous Row" Data

Status
Not open for further replies.

vlfox

Technical User
Oct 13, 2005
40
US
Hello all;

I'm using ADP Enterprise, Reportsmith 4.0 – SQL and trying to upgrade a report that pulls an employee's previous row of Full or Part Time status.

I'm using this derived field for the "OLD" and it works just fine:

(SELECT OLD_[[FT_PT]].[[FT_PT]]
FROM
PS_JOB OLD_[[FT_PT]]
WHERE
((OLD_[[FT_PT]].EMPLID = JOB.EMPLID)
AND
(OLD_[[FT_PT]].EMPL_RCD_NBR = JOB.EMPL_RCD_NBR)
AND
(OLD_[[FT_PT]].EFFSEQ=
(SELECT MAX(INNERALIAS.EFFSEQ)
FROM PS_JOB INNERALIAS
WHERE INNERALIAS.EMPLID = OLD_[[FT_PT]].EMPLID
AND INNERALIAS.EMPL_RCD_NBR = OLD_[[FT_PT]].EMPL_RCD_NBR
AND INNERALIAS.EFFDT = OLD_[[FT_PT]].EFFDT)
AND
OLD_[[FT_PT]].EFFDT =
(SELECT MAX(INNERALIAS.EFFDT)
FROM PS_JOB INNERALIAS
WHERE INNERALIAS.EMPLID = OLD_[[FT_PT]].EMPLID
AND INNERALIAS.EMPL_RCD_NBR = OLD_[[FT_PT]].EMPL_RCD_NBR
AND INNERALIAS.EFFDT < (SELECT MAX(JOB.EFFDT))
AND OLD_[[FT_PT]].[[FT_PT]] = "P"
))))
)

The problem I run into is trying to get the report to ONLY pull the Previous PartTimers. I've confirmed that my table links do NOT "include Unmatched".

When I try to add the selection under the main Select List, I get:

"An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference."

When I try to add the selection under the DataBase Grouping, I get:

"An aggregated expression containing an outer reference must be contained in either the select list, or a HAVING clause subquery in the query whose FROM clause contains the table with the column being aggregated."

Normally when I get these type of messages, I try different variations of turning database grouping off & on, being sure my fields are included or excluded from database grouping correctly, etc. None of my normal troubleshooting ideas are working today.

Any other ideas? As always, appreciate any help - ThX !
 
vlfox,

I am going to preface my answer with, I am an Oracle db user so therefore, I am unable to test this.

I would check your 4th last line
AND INNERALIAS.EFFDT < (SELECT MAX(JOB.EFFDT))

It appears your (SELECT MAX(JOB.EFFDT)) has no FROM or WHERE clause. Remove the SELECT and try running again.

Gotta love RS where the error messages are vague!

Hope this works out for you.

RSGeek
 
My derived field is working fine - I went ahead and tried your idea to see what happens and it actually removes the answer I'm looking for, so I left the DF as it was.

The problem is that I have 2 that have the DF result and another 45 that are null for that DF. I don't want the 45 to pull on the report at all.

Currently I have the report sorted & grouped with a note in the report header to pay no attention to the second group (pay no attention to the man behind the curtain), but that just seems messy.

Yup - those vague messages are something else alright !

ThanX still !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top