473,395 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Auto increment value in queries

Hello folks,

is there any way how to create autoincrement value in query? So every line of my result of query will have values 1,2,3 etc.?

Thank you in advance.

Petr
Mar 29 '07 #1
9 10971
Rabbit
12,516 Expert Mod 8TB
Why do you need this?
Mar 29 '07 #2
developing
110 100+
make a table with an autonumber field?
Mar 29 '07 #3
Hi,

I need select a limited number of rows returned from query.
But this number of records is calculated from this query (I dont know this number before I run this query and this number will vary) - it is located in some field as constant.

for instance:
there is some query with one field named maxrecords = 4 and I need show 4 rows only from this query.
Mar 29 '07 #4
make a table with an autonumber field?
yes it could be answer. But is there any way how to hadle it without any temp table?
Mar 29 '07 #5
Rabbit
12,516 Expert Mod 8TB
There is a way, but before that, how is maxrecords calculated?
Mar 29 '07 #6
it is calculated as formula of some other fields from related query. Used functions are: Round, * and -
Mar 30 '07 #7
Rabbit
12,516 Expert Mod 8TB
What's the exact expression?
Mar 30 '07 #8
What's the exact expression?
newfield: Round((0,3-([field01]/[field02]))*[field02];0)
this function returns integer appx. 1-30, constant for every line. And this number is number of records that I need.

SQL query: SELECT adresy_jen_nove.*, adresy_nahodne_jeden_odkazdeho3_celkovypocet.pocet CATIkontr, adresy_jen_nove_celkovypocet.celkovypocet, Round((0.3-([pocetCATIkontr]/[celkovypocet]))*[celkovypocet],0) AS dovyber_pocet
FROM adresy_jen_nove, adresy_nahodne_jeden_odkazdeho3_celkovypocet, adresy_jen_nove_celkovypocet
WHERE (((adresy_jen_nove.ID) Not In (select id from adresy_nahodne_jeden_odkazdeho3_expdoCATI)))
ORDER BY adresy_jen_nove.typ, adresy_jen_nove.nahoda;
Mar 30 '07 #9
Rabbit
12,516 Expert Mod 8TB
newfield: Round((0,3-([field01]/[field02]))*[field02];0)
this function returns integer appx. 1-30, constant for every line. And this number is number of records that I need.

SQL query: SELECT adresy_jen_nove.*, adresy_nahodne_jeden_odkazdeho3_celkovypocet.pocet CATIkontr, adresy_jen_nove_celkovypocet.celkovypocet, Round((0.3-([pocetCATIkontr]/[celkovypocet]))*[celkovypocet],0) AS dovyber_pocet
FROM adresy_jen_nove, adresy_nahodne_jeden_odkazdeho3_celkovypocet, adresy_jen_nove_celkovypocet
WHERE (((adresy_jen_nove.ID) Not In (select id from adresy_nahodne_jeden_odkazdeho3_expdoCATI)))
ORDER BY adresy_jen_nove.typ, adresy_jen_nove.nahoda;
Create a new query based on the query above with this field.
Expand|Select|Wrap|Line Numbers
  1. DCount("*", "[Name of Above Query]", "adresy_jen_nove.typ<=" & adresy_jen_nove.typ & " AND adresy_jen_nove.nahoda<=" & adresy_jen_nove.nahoda) As Rank
However, this will give every record that has the same typ and nahoda the same Rank. If this is a problem then you may have to go the extra table route.
Mar 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: diong | last post by:
i have a field with a list of wrong ID (random) and i wish to replac them with a sequential (auto-increment) value. how to remove the valu and to add in the sequential ID? Im a newbie in ASP! Pls...
11
by: csomberg | last post by:
SQL 2000 I thought I would throw this out there for some feedback from others. I'd like to know if you feel using MS auto-increment field is a good solution these days or should one grow their...
2
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error...
2
by: Brian Bendtsen | last post by:
Hi Is there at way to reset a table and set the auto increment value to 1000? /Brian Bendtsen
2
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I...
5
by: Germaris | last post by:
Hi there! How should I write a query to get the next auto-increment value of a table? Many thanks in advance for any help. Best regards, Gerry
2
by: skipwater | last post by:
I have two db each have the same table called manufacturers and same fields. db1 has a field called man_ID which is a auto increment field. This contains 90 records but over time the records have...
1
AaronL
by: AaronL | last post by:
Hello, First I would like to say thank you all for your help in the past. I am stumped again. I am creating an e-commerce system and I want to be able to upload images to the server and...
1
by: ghjk | last post by:
I'm a new to postgres. i have a table which is having a colomn with auto increment value. When I insert value to that table, it gives an error. First column is the auto increment one....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.