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!

HELP WITH min(SELECT)

Status
Not open for further replies.

TJVFree

Technical User
Nov 22, 2010
236
US
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top