[GNC] Help with SQL commands

Adrien Monteleone adrien.monteleone at lusfiber.net
Mon Dec 8 00:59:02 EST 2025


Asking a chatbot for code is not reliable. That you *may* get something 
that *appears* to work is a happy accident of probabilities, but I'd 
never rely on it.

There are plenty of SQL references out there to figure out how to write 
a query. Writing them is itself nearly an art form, and you'll only 
learn by doing.

I'd rely on the SQL table reference from the GnuCash wiki and a good SQL 
reference or tutorial site.

Regards,
Adrien

On 12/7/25 11:50 PM, Fred Tydeman wrote:
>>
>>
>>    List of "stocks" in more than one Trading account:
>>
>>
> Google Chrome AI came up with:
> 
>   SELECT
>      c.mnemonic,
>      COUNT(a.guid) AS trading_account_count
> FROM
>      accounts a
> INNER JOIN
>      commodities c ON a.commodity_guid = c.guid
> WHERE
>      a.account_type = 'TRADING'
> GROUP BY
>      c.mnemonic
> HAVING
>      COUNT(a.guid) > 1;
> 
> Again, it found several duplicates.  However, some of them are stocks
> that have the same symbol as a currency.



More information about the gnucash-user mailing list