TOP 5 Query not working

  • Thread starter Thread starter Michael Kintner
  • Start date Start date
M

Michael Kintner

I have a query that for some reason will not show only the top 5 records.

Where this comes from is a report and within that report I have another
report and only wish to show the top 5 records. But the results are very
crazy and sometimes I get nothing.

Any ideas on how to fix this?

Thank you in advance,
Mike
 
I have a query that for some reason will not show only the top 5 records.

Where this comes from is a report and within that report I have another
report and only wish to show the top 5 records. But the results are very
crazy and sometimes I get nothing.

Any ideas on how to fix this?

Thank you in advance,
Mike

"Doctor, I don't feel good. What should I take?" <g>

Please post the SQL view of the query, perhaps with an example of the
data and the results you're getting. It's impossible to determine what
you're doing wrong if you don't tell us what you're doing.

John W. Vinson[MVP]
 
SELECT TOP 5 ProductCodes.ProductCode, TankInfo.TankNumber,
ProductCodes.ProductShortDescr, ProductCodes.ProductLongDescr,
ProductCodes.SpecificGravity, TankInfo.TankID, TankInventory.MeasuredDate,
TankInventory.MeasuredHeightFT, TankInventory.MeasuredHeightIN,
TankInventory.Temperature, TankInventory.Dept, TankInventory.Gravity
FROM TankInfo INNER JOIN (ProductCodes INNER JOIN TankInventory ON
ProductCodes.ProductCodeID = TankInventory.ProductCodeID) ON TankInfo.TankID
= TankInventory.TankID
ORDER BY TankInventory.MeasuredDate DESC;

I try this but only shows 1 record when it should show 5 records. Please
help.

Thanks.
 
SELECT TOP 5 ProductCodes.ProductCode, TankInfo.TankNumber,
ProductCodes.ProductShortDescr, ProductCodes.ProductLongDescr,
ProductCodes.SpecificGravity, TankInfo.TankID, TankInventory.MeasuredDate,
TankInventory.MeasuredHeightFT, TankInventory.MeasuredHeightIN,
TankInventory.Temperature, TankInventory.Dept, TankInventory.Gravity
FROM TankInfo INNER JOIN (ProductCodes INNER JOIN TankInventory ON
ProductCodes.ProductCodeID = TankInventory.ProductCodeID) ON TankInfo.TankID
= TankInventory.TankID
ORDER BY TankInventory.MeasuredDate DESC;

I try this but only shows 1 record when it should show 5 records. Please
help.

If you open the Tables, are there in fact five records in
TankInventory? How many records are there in TankInfo, TankInventory?
Does each TankInventory record have a non-NULL ProductCodeID matching
a record in ProductCodes? If you remove the TOP 5 predicate do you see
just one record, or more than 5?

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top