noob alert.
I have an athletics database and I am trying to calculate the age (in decimal years, ex 23.8665) that an athlete won their first medal in international championship.
I have a query that calculates this for me, with the answer in the field [diff(yd)].
when I run the query, if I right-click the [diff(yd)] column I can select <sort Smallest to Largest> from the drop-down list and it does sort correctly. however, if I want to add sort to the query Access prompts me for a parameter [delta], which is itself a calculated field.
the SQL looks like this:
SELECT [tbl_400m.dat] AS dat, [tbl_athlete.fname]+" "+[tbl_athlete.sname]+" ("+[tbl_athlete.natcode]+")" AS name, tbl_athlete.birthdate, DateSerial(Year([tbl_400m.dat]),Month([tbl_athlete.birthdate]),Day([tbl_athlete.birthdate])) AS [ran(b)],
IIf([tbl_400m.dat]-[ran(b)]>0,Year([tbl_400m.dat])-Year([tbl_athlete.birthdate]),Year([tbl_400m.dat])-Year([tbl_athlete.birthdate])-1) AS delta, IIf([tbl_400m.dat]-[ran(b)]>0,[tbl_400m.dat]-[ran(b)],365+[tbl_400m.dat]-[ran(b)]) AS days, ([delta]+([days]/365)) AS [diff(yd)]
FROM tbl_400m INNER JOIN tbl_athlete ON (tbl_400m.sname = tbl_athlete.sname) AND (tbl_400m.fname = tbl_athlete.fname)
WHERE (((tbl_athlete.birthdate) Is Not Null))
ORDER BY ([delta]+([days]/365));
I tried changing the ORDER BY command to read ORDER BY [diff(yd)]; but when I ran this from SQL View Access still prompted me for the parameter diff(yd).
although a noob I have looked online long enough to have learned that if you are being prompted for an inappropriate parameter then there is usually something wrong with the syntax, but I just can't see what I've done wrong.
appreciate any help you can offer.
thank you.