04. november 2005 - 11:13Der er
4 kommentarer og 1 løsning
Terms in a query
I have a query that looks up a record where the field Arbpassnr IsNull. The records in the table is numbered. Now I want another query to show the actual record and the record befor and after. Lets say that the field Passnr IsNull in record nbr 34 in the table Resapost. I then want to se nbr 33 to 35 as the result in a query. How do I do that? The first query is named NullPassnrResapost
Virksomheder er på vej fra store sprogmodeller, der svarer på spørgsmål, til AI-agenter, der kan udføre opgaver på egen hånd. Det gør teknologien mere nyttig – og langt mere risikabel.
Q_Null holds the Null record Q_NullPlus1 finds the Null record plus the next Q_NullMinus1 finds the Null record plus the previous (actually not the Null record as it is already in Q_NullPlus1) Q_Null_Result joins the two above mentioned
Q_Null SELECT NullPassnrResapost.Id FROM NullPassnrResapost WHERE (((NullPassnrResapost.Arbpassnr) Is Null));
Q_NullPlus1 SELECT TOP 2 NullPassnrResapost.Id, NullPassnrResapost.Arbpassnr FROM NullPassnrResapost LEFT JOIN Q_Null ON NullPassnrResapost.Id = Q_Null.Id WHERE (((NullPassnrResapost.Id)>=DLookUp("ID","Q_Null")));
Q_NullMinus1 SELECT TOP 1 NullPassnrResapost.Id, NullPassnrResapost.Arbpassnr FROM NullPassnrResapost LEFT JOIN Q_Null ON NullPassnrResapost.Id = Q_Null.Id WHERE (((NullPassnrResapost.Id)<DLookUp("ID","Q_Null"))) ORDER BY NullPassnrResapost.Id DESC;
Q_Null_Result SELECT * FROM Q_NullPlus1 UNION SELECT * FROM Q_NullMinus1
1. Create a new query 2. Click OK 3. Do not select any tables or queries - just click Close 4. Select the SQL button or View/SQL .. 5. Paste the code from my answer 6. Save the query under the name above the code
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.