Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Generated Column not found

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2008-03-12 : 08:38:13
I have this

use dbWebsiteLO
SELECT A.vehicleref,A.manufacturer,A.cvehicle_shortmodtext,A.derivative,min(a.ch) as price,A.capid,B.studioimages,(SELECT term FROM vwAllMatrixWithLombardAndShortModel WHERE vehicleref = a.vehicleref and ch = price) FROM vwAllMatrixWithLombardAndShortModel A
LEFT OUTER JOIN dbPubMatrix..tblCarImages B on A.capid = b.capid
WHERE a.source <> 'LOM' AND a.type = 'car' GROUP BY a.vehicleref,a.manufacturer,a.cvehicle_shortmodtext,a.derivative,a.capid,b.studioimages

I get Invalid column name 'price'. I'm trying to reference the "min(a.ch) as price"

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-12 : 08:42:42
[code]SELECT d.vehicleref,
d.manufacturer,
d.cvehicle_shortmodtext,
d.derivative,
d.price,
d.capid,
d.studioimages,
(SELECT x.term FROM vwAllMatrixWithLombardAndShortModel as x WHERE x.vehicleref = d.vehicleref and x.ch = d.price)
FROM (
SELECT A.vehicleref,
A.manufacturer,
A.cvehicle_shortmodtext,
A.derivative,
min(a.ch) as price,
A.capid,
B.studioimages
FROM vwAllMatrixWithLombardAndShortModel as A
LEFT JOIN dbPubMatrix..tblCarImages as B on b.capid = A.capid
WHERE a.source <> 'LOM'
AND a.type = 'car'
GROUP BY a.vehicleref,
a.manufacturer,
a.cvehicle_shortmodtext,
a.derivative,
a.capid,
b.studioimages

) AS d[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -