[AccessD] difficult query??

Gustav Brock gustav at cactus.dk
Tue Nov 9 05:56:57 CST 2004


Hi Pedro

> i have a table [tblA] with 20 fields.
> One of these fields [Number] has a value from 1 to 25.
> I would like each record with a value in field [number] giving the ammount of records of the value of field Number in a new table. And the value of field [Number] must change into "X". All other
> fields must also be present.

> for example

> i have
> tblA

> ID   fieldA  Number etc etc etc
> 1       A           3


> i need 
> ID   fieldA  Number etc etc etc
> 1       A           X
> 1       A           X
> 1       A           X

> Can this been done?

Yes. Create a table, tbzMultiply, with one integer field, Factor, and
create records from 1 to 25 or more, say, 100.

Then use:

  SELECT
    tblA.ID,
    tblA.FieldA,
    ...
    tblA.FieldZ,
    "X" AS [Number]
  FROM
    tblA,
    tbzMultiply
  WHERE
    (tbzMultiply.Factor Between 1 And tblA.[Number])
  ORDER BY
    tblA.ID;

Note the missing join. This is a Cartesian (multiplying) query.

/gustav




More information about the AccessD mailing list