all groups > sql server programming > may 2006 >
You're in the

sql server programming

group:

sql question


sql question x taol
5/30/2006 9:49:02 PM
sql server programming:




i want to a query.

SELECT MAX(fNum) FROM tTable WHERE fDate IN (SELECT MAX(fDate) FROM
tTable WHERE fDate IN (SELECT fDate
FROM tTable WHERE fDate IN (SELECT fDate FROM tTable WHERE
(fRegion="Califo") AND (fProduct="G274") AND (fColor="Brown") AND
(fDate<=#5/13/2006#))))

unfortunately, the upper query is not working in my hope.
i want to following query.

there are records in (fRegion="Califo") AND (fProduct="G274") AND
(fColor="Brown") AND (fDate<=#5/13/2006#).
there are records in maximum fDate in the records.
and then last
there is record of a maximum fNum in the records.



RE: sql question Omnibuzz
5/30/2006 10:31:01 PM
Hi,
Can you give the ddl and insert scripts for sample data and the result you
expect for the given sample data? That way we can understand the problem
Re: sql question Roy Harvey
5/31/2006 7:27:10 PM
As Omnibuzz said, more information is needed.

While your query seems to be written for Access, since this is a SQL
Server group I took the liberty of changing it to SQL Server syntax. I
rewrote the query to eliminate some of the levels, but it should
return the same results as the example:

SELECT MAX(fNum)
FROM tTable
WHERE fDate =
(SELECT MAX(fDate)
FROM tTable
WHERE fRegion = 'Califo'
AND fProduct = '1G274'
AND fColor = 'Brown'
AND fDate <= '13 May 2006')

It doesn't do anything new, but it is perhaps another way to
understand what the original is doing.

Roy Harvey
Beacon Falls, CT

[quoted text, click to view]
AddThis Social Bookmark Button