Add one new record to query

hi The_Doc_Man,

thank you! Nice approach.
Then make its record ID the first record using that order.

if i will set up flag how can i set this record as first?
for example it will be ID = 987 with flag = "Yes".

What is working for me is:

SELECT 1 AS SortKey, Table1.TableName
FROM Table1
ORDER BY Table1.TableName
UNION
SELECT 0 AS SortKey, "Tab3" AS TableName FROM Table1
order by SortKey

I will get here Tab3 as first occurence.

Jacek
 
If you wanted the flagged record to always be first, make the flag a BYTE integer, not a Yes/No field, and make the flag 0 for your header and 1 for "natural" data. Call it "NaturalFlag" or sometime simpler to type. Then for the recordset that contains the header, use ORDER BY NaturalFlag, SortKey. Since 0 comes before 1, this "special" record will come first. But it is the ONLY record with that value, so everything that follows will be "natural" records in the order of your sort key.
 
Thank yuo very much The_Doc_Man
 

Users who are viewing this thread

Back
Top Bottom