Bigint unsigned value out of range
Dear Experienced Forummates,
the problem simplified is this: given a table and I want to list the ID values and the next existing ID values and their difference (alias delta).
create table T1 ( ID serial, primary key (ID) ) engine=InnoDB;
insert into T1 values
(1),(2),(3),(5);
This query works as wanted:
select b.ID,
a.ID as NextID,
a.ID - b.ID as delta
from (select * from T1) as a,
(select * from T1) as b
where a.ID in (select min(ID)
from T1
where ID > b.ID
)
;
If I put it into a sub-query and append a where clause outside of the sub-query:
select *
from (select b.ID,
a.ID as NextID,
a.ID - b.ID as delta
from (select * from T1) as a,
(select * from T1) as b
where a.ID in (select min(ID)
from T1
where ID > b.ID
)
) as c
where delta > 1
;
it says that ERROR 1690 (22003): BIGINT UNSIGNED value is out of range. If I replace 'where delta > 1' with 'having delga > 1' then it also works.
The question is: Why? NextID, if exists, is at least one greater than ID...
Thx,
KEA.
Subject
Written By
Posted
Bigint unsigned value out of range
January 21, 2024 02:58AM
Sorry, only registered users may post in this forum.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.