08. februar 2017 - 10:53Der er
16 kommentarer og 1 løsning
Filter i en Forespørgsel
Hej
Jeg er ny på "Eksperten", er 100% selvoplært i access og beklager på forhånd, hvis mit problem ikke er korrekt beskrevet.
Jeg har en forespørgsel, der ser i en tabel hvor jeg taster fragt priser. dvs at der er: Fra, Til, Pris og Dato. Hvis jeg får en ny pris, hvor fra og til er det samme, taster jeg igen og får en ekstra post med et andet ID
DataID Date City.City City.Country City_1.City City_1.Country PriceAllInclEUR Forwarder ShippingPerson PiceNote 60 24/11/2016 Alba Romania Novi Sad Serbia 850 Quattro-sped Malene Messersmith 102 27/01/2017 Alba Romania Novi Sad Serbia 850 Zaliv Bo Koch 101 27/01/2017 Alba Romania Novi Sad Serbia 900 Ralu Bo Koch
This is an extract of the SQL you gave #6 showing data for Alva to Novi Sad. Taking the price for newest (highest DataID = 102) the price is 850. So you only want too see data for 102, not other records for Alva to Novi Sad?
First make a query and give it a name, I've used qryGroupCity2City in example. This query is only to find highest DataID. SELECT Max(Data.DataID) AS MaxOfDataID, City.City, City.Country, City_1.City, City_1.Country FROM City AS City_1 INNER JOIN (City INNER JOIN Data ON City.CityID = Data.LoadingCity) ON City_1.CityID = Data.DeliveryCity GROUP BY City.City, City.Country, City_1.City, City_1.Country;
Now make a new query using this SQL to give you result
SELECT qryGroupCity2City.MaxOfDataID, qryGroupCity2City.City.City, qryGroupCity2City.City.Country, qryGroupCity2City.City_1.City, qryGroupCity2City.City_1.Country, Forwarder.Forwarder, [Shipping Person].ShippingPerson, Data.Date, Data.PriceAllInclEUR FROM ((qryGroupCity2City INNER JOIN Data ON qryGroupCity2City.MaxOfDataID = Data.DataID) INNER JOIN Forwarder ON Data.ForwarderID = Forwarder.ForwarderID) INNER JOIN [Shipping Person] ON Data.ShippingPersonID = [Shipping Person].ShippingPersonID;
Thanks. I think I forgot to add field Data.PiceNote
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.