G
Guest
I have two tables that I want to merge. But I want a fixed number of entries
in the final result, let's say 100. I want to pull all of the entries from
the first table -- let's say there are 10. I want to pull the remaining items
randomly from the second table; in this case I will need 90, but that number
will vary. I know I can count the number of entries in a table, but I'm not
sure if I can use the result in a SELECT TOP from the second table. I tried
the following:
SELECT TOP (100-[Total Required].SumOfRequired) FROM...
where the query doing the totalling is called Total Required, and the header
displayed when you run the query is called SumOfRequired. This didn't work;
it complains about my syntax.
Is what I'm trying to do doable? It doesn't seem like a completely bizarre
thing. Or am I going about it the wrong way?
By the way, I can handle the randomization; don't worry about that. It's the
variable in the SELECT TOP that has me troubled.
TIA!
in the final result, let's say 100. I want to pull all of the entries from
the first table -- let's say there are 10. I want to pull the remaining items
randomly from the second table; in this case I will need 90, but that number
will vary. I know I can count the number of entries in a table, but I'm not
sure if I can use the result in a SELECT TOP from the second table. I tried
the following:
SELECT TOP (100-[Total Required].SumOfRequired) FROM...
where the query doing the totalling is called Total Required, and the header
displayed when you run the query is called SumOfRequired. This didn't work;
it complains about my syntax.
Is what I'm trying to do doable? It doesn't seem like a completely bizarre
thing. Or am I going about it the wrong way?
By the way, I can handle the randomization; don't worry about that. It's the
variable in the SELECT TOP that has me troubled.
TIA!