i want to make a query which generates in a field values helpppppppppppppp

  • Thread starter asyyyya via AccessMonster.com
  • Start date
A

asyyyya via AccessMonster.com

i have a table with fields:cod, name, number_envelope. I want to make a query
which generates in a field
"cod" value of "number_envelope" times (eq. first value from "cod" is 1 and
"number_envelop" is 10 i want to generate in the field 10 values of 1,if the
"cod " value is 2 and "number_envelope" is 17 i want to generate in the same
field after those 10 values of 1, 17 values of 2,and so on)
i'd like to do these in sql.
 
J

John Vinson

i have a table with fields:cod, name, number_envelope. I want to make a query
which generates in a field
"cod" value of "number_envelope" times (eq. first value from "cod" is 1 and
"number_envelop" is 10 i want to generate in the field 10 values of 1,if the
"cod " value is 2 and "number_envelope" is 17 i want to generate in the same
field after those 10 values of 1, 17 values of 2,and so on)
i'd like to do these in sql.

You can do so by using an auxiliary table. Create a table named NUM
with one field N; fill it with values from 1 to the largest number of
envelopes you'll ever need (be generous!)

Use a "non equi join" query:

SELECT cod, [name], N
FROM yourtable INNER JOIN Num
ON Num.N <= yourtable.[number_envelope];

This has the advantage that you can use "record N of
[number_envelope]" if needed, e.g. record 3 of 17.

John W. Vinson[MVP]
 
A

asyyyya via AccessMonster.com

John said:
i have a table with fields:cod, name, number_envelope. I want to make a query
which generates in a field
[quoted text clipped - 3 lines]
field after those 10 values of 1, 17 values of 2,and so on)
i'd like to do these in sql.

You can do so by using an auxiliary table. Create a table named NUM
with one field N; fill it with values from 1 to the largest number of
envelopes you'll ever need (be generous!)

Use a "non equi join" query:

SELECT cod, [name], N
FROM yourtable INNER JOIN Num
ON Num.N <= yourtable.[number_envelope];

This has the advantage that you can use "record N of
[number_envelope]" if needed, e.g. record 3 of 17.

John W. Vinson[MVP]

help
syntax error (missing operator) in quary expression 'Num.N <= yourtable.
[number_envelope]'
please give me another solution or an explanation for what's happen
 
J

John Spencer

It helps if you post what is failing. The assumption is that you changed
the SQL to match your table and field names. I would guess that you have
entered something incorrectly.

Please copy and post the SQL of your query so that John (and others) can
see what you have entered.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message


asyyyya via AccessMonster.com said:
John said:
i have a table with fields:cod, name, number_envelope. I want to make a
query
which generates in a field
[quoted text clipped - 3 lines]
field after those 10 values of 1, 17 values of 2,and so on)
i'd like to do these in sql.

You can do so by using an auxiliary table. Create a table named NUM
with one field N; fill it with values from 1 to the largest number of
envelopes you'll ever need (be generous!)

Use a "non equi join" query:

SELECT cod, [name], N
FROM yourtable INNER JOIN Num
ON Num.N <= yourtable.[number_envelope];

This has the advantage that you can use "record N of
[number_envelope]" if needed, e.g. record 3 of 17.

John W. Vinson[MVP]

help
syntax error (missing operator) in quary expression 'Num.N <= yourtable.
[number_envelope]'
please give me another solution or an explanation for what's happen
 
Top