| Author |
Topic |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2008-01-16 : 10:53:18
|
| I've got this beast of a statementSELECT * FROM (SELECT P.vehicleref,P.manufacturer,P.model,P.derivative,P.additionalfreetext,P.isLimited,P.isPriceReduction,P.isSpecial, P.created, P.updated, P.capiD,NMF.term, NMF.milespa, NMF.maintained, NMF.ch, ROW_NUMBER() OVER ( PARTITION BY P.VehicleRef ORDER BY NMF.ch ) AS MinCH FROM ( SELECT * FROM vwAllMatrixWithLombardSimple ) P INNER JOIN dbPubMatrix..tblNewMatrixFigures NMF ON P.VehicleRef = NMF. [VehicleRef] WHERE type='car') Q WHERE MinCH = 1 ORDER BY chI need to join dbPubMatrix..tblCarImages.StudioImages IMGS ON P.capID = IMGs.capIDI've tried loads of ways, but always with syntax errors.Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-01-16 : 10:58:51
|
[code]SELECT q.vehicleref, q.manufacturer, q.model, q.derivative, q.additionalfreetext, q.isLimited, q.isPriceReduction, q.isSpecial, q.created, q.updated, q.capiD, q.term, q.milespa, q.maintained, q.chFROM ( SELECT P.vehicleref, P.manufacturer, P.model, P.derivative, P.additionalfreetext, P.isLimited, P.isPriceReduction, P.isSpecial, P.created, P.updated, P.capiD, NMF.term, NMF.milespa, NMF.maintained, NMF.ch, ROW_NUMBER() OVER (PARTITION BY P.VehicleRef ORDER BY NMF.ch) AS MinCH FROM vwAllMatrixWithLombardSimple AS P INNER JOIN dbPubMatrix..tblNewMatrixFigures as NMF ON NMF.[VehicleRef] = P.VehicleRef INNER JOIN dbPubMatrix..tblCarImages.StudioImages AS IMGS ON IMGs.capID = P.capID WHERE {p | nmf}.type = 'car' ) as QWHERE q.MinCH = 1ORDER BY q.ch[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2008-01-17 : 04:43:09
|
| Thanks Peso,I get thisIncorrect syntax near '|'.Cheers |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-17 : 04:59:37
|
quote: {p | nmf}
column type is from which table ? vwAllMatrixWithLombardSimple or dbPubMatrix..tblNewMatrixFigures ?You suppose to change this to the actual table alias where column type is from. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|