Bug 131448 - Can Not Group in SQL on EXTRACT(YEAR FROM in Firebird Embedded
Summary: Can Not Group in SQL on EXTRACT(YEAR FROM in Firebird Embedded
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.4.2.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-20 17:44 UTC by putmann1013
Modified: 2021-02-09 12:52 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description putmann1013 2020-03-20 17:44:50 UTC
Description:
EXTRACT(YEAR From Date Time ) produces an error in a SQL GUI when grouping exists in a database on EXTRACT(YEAR FROM below
SELECT "Car", SUM("Cost") , EXTRACT(YEAR FROM "ServiceDate")
FROM "tblService"
GROUP BY "Car", EXTRACT(YEAR FROM "ServiceDate")
ORDER BY EXTRACT(YEAR FROM "ServiceDate") DESC

Actual Results:
SQL Status: HY000
Error code: 1000

syntax error, unexpected $end, expecting BETWEEN or IN or SQL_TOKEN_LIKE

Expected Results:
Car	SUM	Year
2015	121	2020
2015	546	2019
2015	399	2018
2015	187	2017
2015	98	2016



Reproducible: Always


User Profile Reset: No



Additional Info:
It should have grouped on EXTRACT(YEAR From Date Time )
Comment 1 m_a_riosv 2020-03-20 21:59:00 UTC
I'm wrong or you can't use order clause, sort order is fixed GROUP BY in the order of the fields.

https://firebirdsql.org/manual/nullguide-aggrfunc.html#nullguide-aggrfunc-groupby
Comment 2 putmann1013 2020-03-27 01:42:10 UTC
SQLstill errors even when Order by is removed.
Comment 3 Robert Großkopf 2020-03-27 15:54:36 UTC
Can't see anybody, who has confirmed a buggy behavior here.
Have tested this:

SELECT "Car", SUM("Cost") , EXTRACT(YEAR FROM "ServiceDate") AS "Year"
FROM "tblService"
GROUP BY "Car", "Year"
ORDER BY "Year" DESC

No problem to execute this query. But you can't change from this query to the query-GUI. It won't understand the code.

Then I tried
SELECT "Car", SUM("Cost") , EXTRACT(YEAR FROM "ServiceDate")
FROM "tblService"
GROUP BY "Car", EXTRACT(YEAR FROM "ServiceDate")
ORDER BY EXTRACT(YEAR FROM "ServiceDate") DESC

Without any alias and it throws an error, because Base couldn't understand this code. So I switched to direct SQL executing and this code works, too.

Tested with LO 6.4.2.2 on OpenSUSE 15.1 64bit rpm Linux

So I couldn't find any buggy behavior here. I switch it back to unconfirmed, because it must be confirmed by other person like the bug reporter.
Comment 4 putmann1013 2020-03-27 19:19:06 UTC
I guess it was my fault for omitting the alias. Thanks for answer.