Is there a way to create a query ,that does the following. There is a table with column name, identification number and a quantity. The query should represent the name and identifiaction number. Both should be representet quantity times.
This is my table@cheberdy You're new here. Welcome. Your question is unclear. Can you give us an example of the data you have and the results you want.
quantity is a number and it gives the number of recordsWhat's your ultimate goal? Based on your example above, do you want 5 records in a table?
SELECT [name], id
FROM TableName, TallyTable
WHERE TallyTable.ID<=TableName.quantity
That I understand. What I meant is what is the purpose of the query?quantity is a number and it gives the number of records
How do I create this tally tabel@theDBguy - think you meant
Code:SELECT [name], id FROM TableName, TallyTable WHERE TallyTable.ID<=TableName.quantity
The tally table ID's need to run consecutively from 1 to at least whatever number is big enough for the maximum quantity in your quantity field
It is for creating labelsThat I understand. What I meant is what is the purpose of the query?
How do I create a tally table in accessHere's an example query using a Tally table.
(untested)SQL:SELECT [name], id FROM TableName, TallyTable WHERE TallyTable.ID<=TableName.id
Hope that helps...
Is it possible to do the same with a loopsee post #9
it is just a table with one column
Haha, good thing I said "(untested)."@theDBguy - think you meant
Code:SELECT [name], id FROM TableName, TallyTable WHERE TallyTable.ID<=TableName.quantity
The tally table ID's need to run consecutively from 1 to at least whatever number is big enough for the maximum quantity in your quantity field
But you never set what i is???Maybe something like
Declare i as Integer
Select mytable.Quantity
from mytable
while mytable.Quantity < i
Begin
Select mytable.Id, mytable.name from mytable
Set i = i+1
End