Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread SQL to increment numbers to a result
Thu, Nov 15 2007 1:55 AMPermanent Link

"Adam H."
Hi,

I have a query result that I would like to populate with numbers starting
from a certain range.

ie:

if I execute:

select T.Ticket, T.SomeNumber
From Tickets T
where (A condition exists)

I get a result set. What I would like to do to the result set is something
in SQL like:

incNo := 101; //or whatever I assign
Query.First;
while not Query.Eof do
begin
Table.Locate('Ticket', QueryTicket.value);
TableSomeNumber := incNo;
Table.Post;
inc(incNo);
Query.next;
end;

Is it possible to get SQL to increment numbers, or will I need to code it in
delphi as above?

Thanks & Regards

Adam.
Thu, Nov 15 2007 2:42 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


Have a look at RUNSUM - it might do the job

Roy Lambert
Thu, Nov 15 2007 9:24 AMPermanent Link

"Robert"

"Adam H." <ahairsub4@pleaseREMOVEme.jvxp.com> wrote in message
news:CFD74A4B-B4A1-42E6-B4D7-FB4FD8F3B7E4@news.elevatesoft.com...
> Hi,
>
> I have a query result that I would like to populate with numbers starting
> from a certain range.
>

The following will give you the sequential numbers

select field into memory\temp from customer order by field;
optimize table memory\temp;
alter table memory\temp last autoinc  100;
alter table memory\temp add myautoinc autoinc;
select * from memory\temp;

Robert


Thu, Nov 15 2007 6:19 PMPermanent Link

"Adam H."
Hi Robert and Roy,

I guess there's more than one way to skin a cat ey?

Thank you very much for your help! Got what i need, and all working
smoothly!

Best Regards

Adam.
Image