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.

Jobs

HELP WITH min(SELECT)

HELP WITH min(SELECT)

(OP)
I’m looking for some help with my sql.
• What I’m trying to do is ‘his
• Take the Date of Service
• Group all matching Master Account Number

Have sql look at the group of Master Account = Then find the lowest Date of Service in at Master Account group.

So the outcome would look like this. I have the sql I’ve been working with, and occasional it does find the min service date. Any help would be appreciated


SELECT
COLLACCT@.RECNUM AS 'PSBAcctNumber',
(SELECT ACCT.DATEOFSERVICE FROM COLLACCT@ AS ACCT WHERE ACCT.MASTERACCOUNT = MasterAccount ORDER BY ACCT.DATEOFSERVICE LIMIT 1 ) AS 'minDateofService',
COLLACCT@.DATEOFSERVICE AS 'DateofService',
COLLACCT@.PRINCIPALBALANCE AS 'PrincipalBalance',
COLLACCT@.STATUSCODE AS 'StatusCode',
COLLACCT@.COLLECTORNUMBER AS 'CollectorNumber',
COLLDEBT@.RECNUM AS 'MasterAccount'
FROM COLLACCT@
INNER JOIN COLLDEBT@ ON COLLACCT@.MASTERACCOUNT = COLLDEBT@.RECNUM
LEFT JOIN AUXECASCORE@ ON COLLDEBT@.RECNUM = AUXECASCORE@.COLLDEBTLINK
LEFT JOIN COLLCLT@ ON COLLCLT@.RECNUM = COLLACCT@.CLIENTNUMBER
LEFT JOIN AUXDEBTOR@ ON AUXDEBTOR@.DEBTORMASTER = COLLDEBT@.RECNUM
LEFT JOIN AUXACCTMISC@ ON AUXACCTMISC@.COLLACCTLINK = COLLACCT@.RECNUM
WHERE
StatusCode IN ('TTL')
AND CollectorNumber IN ('03')
AND COLLCLT@.TYPEDEBT NOT IN ('7')
GROUP BY
PSBAcctNumber
ORDER BY
MasterAccount,
PSBAcctNumber


TCB

RE: HELP WITH min(SELECT)

This doesn't look like Jet SQL as used in Access. Are you sure you have posted it to the correct forum here?

Or is this a pass through query to a client/server system (and if so, which)?.

John

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!

Resources

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