Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Ordering a query

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
haggmar
Asked:
haggmar
  • 2
  • 2
  • 2
  • +4
1 Solution
 
ildcCommented:
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
 
haggmarAuthor Commented:
dont have any field
0
 
TextReportCommented:
You will need a field to keep a track on this. An AutoNumber Field will do the job.

Cheers, Andrew
0
Technology Partners: 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!

 
haggmarAuthor Commented:
yes i know i can do that but is there any other say to do it without such a field??
0
 
ildcCommented:
Nope,

Because access does not store internal record numbers.

regards
0
 
dapperryCommented:
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
 
Arthur_WoodCommented:
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
 
dapperryCommented:
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
 
nico5038Commented:

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
 
NetminderCommented:
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!

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now