Back to Community
How could I get the sum of market_cap based on country?

I want to get the sum of market_cap for each country.
And I'm trying to use the code

from sqlalchemy.sql import func  
fundamental_df = get_fundamentals(  
        query(  
            func.sum(fundamentals.valuation.market_cap)  
        ).group_by(fundamentals.company_reference.business_country_id),  
    )  

but I got "Importing func from sqlalchemy.sql raised an ImportError"