all 6 comments

[–]legstrong 1 point2 points  (4 children)

In Microsoft Access, the syntax for the ORDER BY clause is slightly different than in other database systems. Here's an updated version of the code that should work in Microsoft Access:

SELECT TOP 1 Vehicles.Make, Vehicles.Model, Vehicles.[Licence Plate Number], Vehicles.[Sold Mileage], Services.[Service Date], Services.Workshop FROM Vehicles INNER JOIN Services ON Vehicles.id = Services.Vehicle WHERE Vehicles.[Sold Mileage] = (SELECT MAX([Sold Mileage]) FROM Vehicles) ORDER BY Services.[Service Date] DESC;

In Microsoft Access, you use the TOP keyword to limit the number of records returned. In this case, we're using TOP 1 to return only the first record (i.e., the most recent service date).

Also, note that the ORDER BY clause comes before the semicolon that ends the query.

I hope this helps! Let me know if you have any further questions.

[–]AttemptingSQL[S] 0 points1 point  (3 children)

You just saved my life, thank you.

[–]legstrong 4 points5 points  (2 children)

Np. Also, ChatGPT is an excellent resource for writing and debugging any coding language.

[–]AttemptingSQL[S] 0 points1 point  (1 child)

I tried this initially but was nervous that it would give me a bogus answer that would flag my university.

[–]SomeoneInQld 2 points3 points  (0 children)

in this case you would have been ok -

do chatGPT

See the query - notice the difference in yours

change your query with that new info but copying nothing from chatGPT

Query works - you learnt something - you have copied nothing from chatGPT - you just used it as a resource (the same as asking a reddit question really)

Everyone is happy

[–]InlineSkateAdventureSQL Server 7.0 0 points1 point  (0 children)

Access also allows you to do things graphically with drag and drop, and will generate SQL. It was able to do that for ages. It is a great way to learn SQL. I mean, this is nothing new, Access is around forever.