|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What is wrong with this SQL statementWhen I run the query below in QA, it works fine and gives me some results. When I try to run the same query in Microsoft Query from an Excel sheet, it fails. I get the error "No column was specified for column 1 of 'FSS'. Statements could not be prepared". The query I try to run is this - SELECT FF.FinFordelNr, FF.FordelingsSats, FF.FinSelskabNr,FF.DatoGyldigPr FROM FinFordelSats FF JOIN (SELECT MAX(DatoGyldigpr) MaxDato, FinFordelNR FROM FinFordelsats GROUP BY (FinFordelNR)) FSS ON FF.DatoGyldigPr = FSS.MaxDato AND FF.FinFordelNr = FSS.finFordelNr (it's actually more than just this, but it's this single part that fails). I'm not familiar with how Microsoft Query works from Excel, so it might be very simple thing I'm missing. Regards Steen Try inserting an AS in this.
JOIN (SELECT MAX(DatoGyldigpr) AS MaxDato, FinFordelNR HTH, Jens Suessmeyer. Jens wrote:
> Try inserting an AS in this. Sorry...I should of course have mentioned that I already tried that, but > > JOIN (SELECT MAX(DatoGyldigpr) AS MaxDato, FinFordelNR > > HTH, Jens Suessmeyer. > the result are the same. I've also tried to put the alias in ' ' ( AS 'MaxDato') which I can see has been done with the other column aliases that have been created automatically by MS Query. I've also tried to enter the full 3-part name (databasename.dbo.Tablename) which also seems to be how MS Query is doing it, but that doesn't help either. Regards Steen |
|||||||||||||||||||||||