[GNC] Help with SQL commands

Cam Ellison cam at ellisonet.ca
Mon Dec 8 10:51:32 EST 2025


On 2025-12-07 21:59, Adrien Monteleone wrote:
> 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.
>
Currencies are also commodities.

And I'll second Adrien's excellent suggestion.

Cheers

Cam



More information about the gnucash-user mailing list