複数の順序付け列を使用し、それらの列の順序が異なる場合、出力が異なるのは正常ですか?
例えば:
create table test_table (
id int8 not null,
year int4 not null,
province varchar(16) not null,
dangerous bool,
sector varchar(9) not null,
unit varchar(3) not null,
amount numeric not null
);
insert into test_table (id, year, province, dangerous, sector, unit, amount) values (1, 2012, 'W_FL', true, 'FOTOG', 'TNE', 55);
insert into test_table (id, year, province, dangerous, sector, unit, amount) values (2, 2012, 'E_FL', true, 'CHEM', 'TNE', 54);
insert into test_table (id, year, province, dangerous, sector, unit, amount) values (3, 2012, 'W_FL', true, 'CHEM', 'TNE', 74);
insert into test_table (id, year, province, dangerous, sector, unit, amount) values (4, 2012, 'E_FL', true, 'FOTOG', 'TNE', 4);
insert into test_table (id, year, province, dangerous, sector, unit, amount) values (5, 2012, 'LIM', true, 'FOTOG', 'TNE', 4);
最初のクエリ:
select
*
from
test_table test
where
test.year=2012
order by
test.province asc,
test.sector asc
limit 2;
どの出力:
ID YEAR PROVINCE DANGEROUS SECTOR UNIT AMOUNT
2 2012 E_FL TRUE CHEM TNE 54
4 2012 E_FL TRUE FOTOG TNE 4
2 番目のクエリ:
select
*
from
test_table test
where
test.year=2012
order by
test.sector asc,
test.province asc
limit 2;
このクエリは、別のものを返します。
ID YEAR PROVINCE DANGEROUS SECTOR UNIT AMOUNT
2 2012 E_FL TRUE CHEM TNE 54
3 2012 W_FL TRUE CHEM TNE 74
制限によって 2 番目の order by 句のみが使用されているかのようです...両方のクエリが同じ出力になるはずであるという私の仮定を誰かが検証できますか?