Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Ordering a query

Posted on 2002-07-09
10
Medium Priority
?
244 Views
Last Modified: 2008-02-26
I have a sqlquery which i run in my vbapp using an access db. here is the query: Select Type, PLUNummer, VaregruppeNummer, Navn, Sum(Stk) AS SumStk, PrisLevel, Pris, Sum(Belop) AS SumBelop, ReseptFaktor, TilKoInfo, TilKjokkenPrinter, TilKundeKvittering, DummyBehandling, KjokkenPrinterDone, Momssats, Sum(rabattbelop) As SumRabattBelop From BestillingsTransaksjoner  Group By BestillingsNr, Type, PLUNummer, VaregruppeNummer, Navn, PrisLevel, Pris, ReseptFaktor, TilKoInfo, TilKjokkenPrinter, TilKundeKvittering, DummyBehandling, KjokkenPrinterDone, Momssats, rabattBelop Having (((BestillingsNr) = 10090))


The query works fine there is only one problem, i dont get the posts sorted as they where inserted into the table I know that i could have a new field describing which where inserted first, but i dont have that, is there any other way?
0
Comment
Question by:haggmar
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 7

Expert Comment

by:ildc
ID: 7140615
If there is one sort of field that indicates the order in which you inserted the records, (primary key autonumber ??)you have to put it first in the group by line. If you don't have such a field, then it seems pretty impossible to me.

regards
0
 

Author Comment

by:haggmar
ID: 7140621
dont have any field
0
 
LVL 28

Expert Comment

by:TextReport
ID: 7140630
You will need a field to keep a track on this. An AutoNumber Field will do the job.

Cheers, Andrew
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:haggmar
ID: 7140631
yes i know i can do that but is there any other say to do it without such a field??
0
 
LVL 7

Expert Comment

by:ildc
ID: 7140638
Nope,

Because access does not store internal record numbers.

regards
0
 
LVL 3

Expert Comment

by:dapperry
ID: 7140894
I often create a datetime field called InsertDate to store when the record was actually inserted. I don't know if you have a field like this, but you could use that. That said, you should probably add an autonumber field as well.

:) dapperry
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7141002
the concept of INSERT ORDER in a true relational database is totally AD HOC, as it generally is of little or no intrinsic meaning.  Most database management systems do not AUTOMATICALLY keep track of when a record was inserted - that is generally up to the designer of the table(s) to add a field, to each table, to store that information, if it is important.

If you have not already designed such a field into your tables, then there is almost NO WAY to determine that information AFTER THE FACT.  The data that is currently in the table is in a completely arbitrary order, which has very little to do with the order in which the records were actually added.  If, on the other hand, you have an autonumber field(Access), then THAT field will tell you what order the records were added.  Or, as has been suggested by others, if you have a TimeStamp field, into which you record the Date and Time when a record was added to the table, then here again, you can determine the order in which records were added.  But in the absence of either of those types of fields, then NO, you cannot determine what order the records were added.

Arthur Wood
0
 
LVL 3

Expert Comment

by:dapperry
ID: 7141102
Arthur_Wood,
     Would it be safe in saying then, if there had NEVER been an index on the table, that the order would simply be from top to bottom?

:) dapperry
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7260158

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7296328
Per recommendation, points NOT refunded and question closed.

Netminder
CS Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question