skip to Main Content

Postgresql – SQLAlchemy – column must appear in the GROUP BY clause or be used in an aggregate function

I am using sqlalchemy with postgresql, Tables Shape[id, name, timestamp, user_id]#user_id referring id column in user table User[id, name] this query - query1 = self.session.query(Shape.timestamp, Shape.name, User.id, extract('day', Shape.timestamp).label('day'), extract('hour', Shape.timestamp).label('hour'), func.count(Shape.id).label("total"), ) .join(User, User.id==Shape.user_id) .filter(Shape.timestamp.between(from_datetime, to_datetime)) .group_by(Shape.user_id) .group_by('hour') .all()…

VIEW QUESTION

How to insert nested JSON into PostgreSQL

CREATE TABLE Log ( "Name" TEXT, "Age" TEXT, "Country" TEXT, "Numbers" TEXT ); SELECT "Country", "Numbers" FROM json_populate_record( null:: log, '{ "Name": "qazwsx", "HostName": "Age", "Address": { "Country": "MNB", "Numbers": [ { "Cell": 7418520 } ] } }'); SELECT *…

VIEW QUESTION
Back To Top
Search