[GNC] Help with SQL commands

Fred Tydeman tydeman.fred at gmail.com
Sun Dec 7 23:54:48 EST 2025


For finding a "stock" in more than one NameSpace, Google AI came up with:

SELECT
    mnemonic,
    COUNT(DISTINCT namespace) AS namespace_count
FROM
    commodities
GROUP BY
    mnemonic
HAVING
    COUNT(DISTINCT namespace) > 1;

I have run that in sqlite3 command line and it found several duplicates.
One down, three to go.

How do I add this to:
https://wiki.gnucash.org/wiki/GnuCash_SQL_Examples


On Mon, Dec 8, 2025 at 4:27 PM Fred Tydeman <tydeman.fred at gmail.com> wrote:

> I had GnuCash create a SQL database (sqlite3).
>
> I have three different SQL GUI programs:
>   dbeaver-ce, SQLiteStudio, DB_Browser
>
> I have found three online pages about SQL and GnuCash:
>   https://wiki.gnucash.org/wiki/SQL
>   https://wiki.gnucash.org/wiki/GnuCash_SQL_Examples
>   https://wiki.gnucash.org/wiki/images/8/86/Gnucash_erd.png
>
> I am trying to create SQL queries to find errors in my GnuCash setup:
>   List of "stocks" no longer owned, but still getting Online Quotes:
>   List of "stocks" still owned, but not getting Online Quotes:
>   List of "stocks" in more than one Namespace:
>   List of "stocks" in more than one Trading account:
>
> I can figure out some of the table columns that I need,
> but need help creating the full queries.
>
> I am running on Fedora Linux (35 thru 43) on Intel x86_64 with GnuCash
> 5.12 and 5.13
>


More information about the gnucash-user mailing list