clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2805502 fiddles created (40744 in the last week).

select rdb$get_context('SYSTEM', 'ENGINE_VERSION') as version from rdb$database;
VERSION
3.0.5
 hidden batch(es)


create table t ( a integer, b integer, c integer )
 hidden batch(es)


insert into t select 1, 6, 10 from rdb$database union all select 1, 6, 20 from rdb$database union all select 1, 7, 30 from rdb$database union all select 1, 7, 40 from rdb$database union all select 2, 8, 15 from rdb$database union all select 2, 8, 25 from rdb$database union all select 2, 9, 35 from rdb$database union all select 2, 9, 45 from rdb$database
8 rows affected
 hidden batch(es)


select * from t;
A B C
1 6 10
1 6 20
1 7 30
1 7 40
2 8 15
2 8 25
2 9 35
2 9 45
 hidden batch(es)


-- inspired by https://stackoverflow.com/questions/58226348 select b, c from t where a = 1 and b = 7 order by b, c
B C
7 30
7 40
 hidden batch(es)


select b, c + 50 from t where a = 2 and b = 8 order by b, c
B ADD
8 65
8 75
 hidden batch(es)


select b, c from t where a = 1 and b = 7 order by b, c union all select b, c + 50 from t where a = 2 and b = 8 order by b, c
Dynamic SQL Error SQL error code = -104 Token unknown - line 2, column 3 union
 hidden batch(es)


select b, c from t where a = 1 and b = 7 union all select b, c + 50 from t where a = 2 and b = 8 order by b, c
Dynamic SQL Error SQL error code = -104 Invalid command invalid ORDER BY clause
 hidden batch(es)


select b, c as c from t where a = 1 and b = 7 union all select b, c + 50 from t where a = 2 and b = 8 order by b, c
Dynamic SQL Error SQL error code = -104 Invalid command invalid ORDER BY clause
 hidden batch(es)


select b, c as c from t where a = 1 and b = 7 union all select b, c + 50 as c from t where a = 2 and b = 8 order by b, c
Dynamic SQL Error SQL error code = -104 Invalid command invalid ORDER BY clause
 hidden batch(es)


select b, c from t where a = 1 and b = 7 union all select b, c + 50 from t where a = 2 and b = 8 order by 1, 2
B C
7 30
7 40
8 65
8 75
 hidden batch(es)


select * from (select b, c from t where a = 1 and b = 7) as t1 union all select * from (select b, c + 50 from t where a = 2 and b = 8) as t2 order by b, c
Dynamic SQL Error SQL error code = -104 Invalid command no column name specified for column number 2 in derived table T2
 hidden batch(es)


select * from (select b, c from t where a = 1 and b = 7 order by b, c) as t1 union all select * from (select b, c + 50 from t where a = 2 and b = 8 order by b, c) as t2
Dynamic SQL Error SQL error code = -104 Invalid command no column name specified for column number 2 in derived table T2
 hidden batch(es)


select * from (select b, c from t where a = 1 and b = 7 order by b, c) as t1
B C
7 30
7 40
 hidden batch(es)


select * from (select b, c + 50 from t where a = 2 and b = 8 order by b, c) as t2
Dynamic SQL Error SQL error code = -104 Invalid command no column name specified for column number 2 in derived table T2
 hidden batch(es)


select b, c + 50 from t where a = 2 and b = 8
B ADD
8 65
8 75
 hidden batch(es)


select * from (select b, c + 50 from t where a = 2 and b = 8)
Dynamic SQL Error SQL error code = -104 Invalid command no column name specified for column number 2 in derived table <unnamed>
 hidden batch(es)