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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when ORDER BY Clause added

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I have the following query:

SELECT top 1 dbo.zISSHAREHOLDERS.HOLDERID AS 'AccountNo', dbo.zISFUND.FUNDID as 'FundCode', dbo.zISFUND.FUNDNAME as 'FundName', dbo.zISNAVS.NAV AS 'FundPrice', dbo.zISHOLDINGS.SUMORIGSHARES as 'Units', dbo.zISHOLDINGS.CURRENCY as 'Currency', /*CONVERT(NUMERIC, */dbo.zISNAVS.NAV * dbo.zISHOLDINGS.SUMORIGSHARES/*)*/ AS 'MarketValue', dbo.zISSHAREHOLDERS.HOLDERNAME as 'FirstName', dbo.zISNAVS.NAVDATE as 'DATE', dbo.zISSALESPEOPLE.CONTACTNAME as 'ConsultName'
FROM
dbo.zISFUND INNER JOIN dbo.zISNAVS
ON
dbo.zISFUND.FUNDID /*Fund Code*/ = dbo.zISNAVS.FUNDID
INNER JOIN dbo.zISHOLDINGS
ON
dbo.zISFUND.FUNDID = dbo.zISHOLDINGS.FUNDID
INNER JOIN dbo.zISSHAREHOLDERS
ON
dbo.zISSHAREHOLDERS.HOLDERID = dbo.zISHOLDINGS.HOLDERID
LEFT JOIN dbo.zISSALESPEOPLE
ON
dbo.zISSHAREHOLDERS.RPID LIKE dbo.zISSALESPEOPLE.RPID

WHERE

( dbo.zISSHAREHOLDERS.HOLDERID LIKE '24301'
AND dbo.zISNAVS.NAVDATE <= GETDATE())

GROUP BY

dbo.zISNAVS.NAVDATE,
dbo.zISSHAREHOLDERS.HOLDERID,
dbo.zISSHAREHOLDERS.HOLDERNAME,
dbo.zISFUND.FUNDID,
dbo.zISFUND.FUNDNAME,
dbo.zISNAVS.NAV,
dbo.zISHOLDINGS.SUMORIGSHARES,
dbo.zISHOLDINGS.CURRENCY,
dbo.zISSALESPEOPLE.CONTACTNAME

/*ORDER BY
dbo.ISNAVS.NAVDATE*/


The moment I comment out the Order By clause, it comes up with the following error:

Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'dbo.ISNAVS' does not match with a table name or alias name used in the query.

Can someone help me with this please? My SP skills are unfortunately still quite unrefined :cool:

Thanks a mill

Craftor
 
in Your query that table is named zISNAVS, not &quot;ISNAVS&quot; is that intended?
PFR
 
*smacks head* NOO!

Thanks PFR guess I had a dumb blonde moment with that one

:-|
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top