2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
"""
|
|
|
|
ID: derived-table-18
|
|
|
|
TITLE: Aggregate inside derived table
|
|
|
|
DESCRIPTION:
|
2022-02-04 19:05:19 +01:00
|
|
|
FBTEST: functional.arno.derived_tables.18
|
2022-01-28 18:56:36 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
init_script = """CREATE TABLE Table_10 (
|
2021-04-26 20:07:00 +02:00
|
|
|
ID INTEGER NOT NULL,
|
|
|
|
GROUPID INTEGER,
|
|
|
|
DESCRIPTION VARCHAR(10)
|
|
|
|
);
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (0, NULL, NULL);
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (1, 1, 'one');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (2, 1, 'two');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (3, 2, 'three');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (4, 2, 'four');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (5, 2, 'five');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (6, 3, 'six');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (7, 3, 'seven');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (8, 3, 'eight');
|
|
|
|
INSERT INTO Table_10 (ID, GROUPID, DESCRIPTION) VALUES (9, 3, 'nine');
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
"""
|
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
test_script = """SELECT
|
2021-04-26 20:07:00 +02:00
|
|
|
dt.*
|
|
|
|
FROM
|
|
|
|
(SELECT t1.GROUPID, Count(t1.ID) FROM Table_10 t1 GROUP BY t1.GROUPID) dt (GROUPID, ID_COUNT)
|
|
|
|
WHERE
|
2021-12-22 20:25:10 +01:00
|
|
|
dt.GROUPID >= 2;"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-28 18:56:36 +01:00
|
|
|
expected_stdout = """ GROUPID ID_COUNT
|
2021-04-26 20:07:00 +02:00
|
|
|
============ =====================
|
|
|
|
2 3
|
|
|
|
3 4
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-28 18:56:36 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|