×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Selecting/Filtering from "Previous Row" Data

Selecting/Filtering from "Previous Row" Data

Selecting/Filtering from "Previous Row" Data

(OP)
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 !

RE: Selecting/Filtering from "Previous Row" Data

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

RE: Selecting/Filtering from "Previous Row" Data

(OP)
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 !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close