[Bug 168149] Want the ability to apply SQL queries to a selected range
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Thu Aug 28 11:28:12 UTC 2025
https://bugs.documentfoundation.org/show_bug.cgi?id=168149
--- Comment #2 from Eyal Rozenberg <eyalroz1 at gmx.com> ---
(In reply to Heiko Tietze from comment #1)
> SQL query in Calc?
We have tables in calc, and we often want to generate new tables with
derivative data. Pivot Tables work for simple cases, but not beyond that. But
pivot tables have a lot of code supporting their dynamism; if we stick to just
generating contents of cells, it should not be difficult - UI-wise at least -
to allow for complex SELECT queries.
> And how do you think is Calc blocking Database/Database-Queries?
My "database" in calc is my selection. Tell me, how do I query it?
> Cannot wrap my mind around this idea. You mean something like <FUNCTION> at
> <RANGE> for <TARGET> like "SUM at A1:A10 for B1".
No, not a function. That might be an interesting direction, but I mean
something more straightforward than that.
Example: You enter the following values
+---------+------------------+
| name | favourite color |
+---------+------------------+
| Alice | blue |
+---------+------------------+
| Bob | green |
+---------+------------------+
| Charlie | pink |
+---------+------------------+
| Daria | green |
+---------+------------------+
| Eve | green |
+---------+------------------+
Then, you select this cell range, then invoke an UNO command for applying an
SQL query. In the dialog that opens up, you enter:
SELECT t1.name, t2.name
FROM selection_ AS t1, selection_ AS t2
WHERE t1.'favourite color' = t2.'favourite color' AND t1.name < t2.name;
and you also toggle the checkboxes "use first row as column names", and
"results as new sheet" and press ok.
You now get a new sheet which contains
+---------+------------+
| t1.name | t2.name |
+---------+------------+
| Bob | Daria |
+---------+------------+
| Daria | Eve |
+---------+------------+
| Bob | Eve |
+---------+------------+
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Libreoffice-ux-advise
mailing list