Here’s the latest debug output.
The query still doesn’t work. @George
{
"qAddon": {
"options": {
"connection": "pg13",
"sql": {
"type": "select",
"columns": [
{
"table": "t_orders",
"column": "id"
},
{
"table": "t_orders",
"column": "order_name"
},
{
"table": "t_orders",
"column": "created_on"
},
{
"table": "t_order_details",
"column": "discount",
"alias": "total_discount",
"aggregate": "SUM"
},
{
"table": "t_order_details",
"column": "gross_amount",
"alias": "total_amt",
"aggregate": "SUM"
}
],
"table": {
"name": "t_orders"
},
"primary": "id",
"joins": [
{
"table": "t_order_details",
"column": "*",
"type": "INNER",
"clauses": {
"condition": "AND",
"rules": [
{
"table": "t_order_details",
"column": "order_id",
"operator": "equal",
"value": {
"table": "t_orders",
"column": "id"
},
"operation": "="
}
]
},
"primary": "id"
}
],
"query": "SELECT t_orders.id, t_orders.order_name, t_orders.created_on, SUM(t_order_details.discount) AS total_discount, SUM(t_order_details.gross_amount) AS total_amt\nFROM t_orders\nINNER JOIN t_order_details ON t_order_details.order_id = t_orders.id\nWHERE t_orders.created_on > '2022-10-11'\nGROUP BY t_orders.id, t_orders.order_name, t_orders.created_on\nORDER BY t_orders.id ASC",
"params": [
],
"groupBy": [
{
"table": "t_orders",
"column": "id"
},
{
"table": "t_orders",
"column": "order_name"
},
{
"table": "t_orders",
"column": "created_on"
}
],
"wheres": {
"condition": "AND",
"rules": [
{
"id": "t_orders.created_on",
"field": "t_orders.created_on",
"type": "datetime",
"operator": "greater",
"value": "2022-10-11",
"data": {
"table": "t_orders",
"column": "created_on",
"type": "datetime",
"columnObj": {
"type": "timestamp",
"default": "now()",
"primary": false,
"unique": false,
"nullable": false,
"name": "created_on"
}
},
"operation": ">",
"table": "t_orders"
}
],
"conditional": null,
"valid": true
},
"sub": {
"state_changes": {
"type": "SELECT",
"table": {
"name": "t_order_state_changes",
"alias": "state_changes"
},
"key": "order_id",
"columns": [
{
"table": "state_changes",
"column": "state_id"
}
],
"primary": "id",
"joins": [
],
"query": "SELECT state_id\nFROM t_order_state_changes AS state_changes",
"params": [
]
}
},
"orders": [
{
"table": "t_orders",
"column": "id",
"direction": "ASC"
}
],
"sort": null,
"dir": "asc"
},
"test": true
},
"query": {
"sql": "select \"t_orders\".\"id\", \"t_orders\".\"order_name\", \"t_orders\".\"created_on\", sum(\"t_order_details\".\"discount\") as \"total_discount\", sum(\"t_order_details\".\"gross_amount\") as \"total_amt\" from \"t_orders\" inner join \"t_order_details\" on \"t_order_details\".\"order_id\" = \"t_orders\".\"id\" where \"t_orders\".\"created_on\" > $1 group by \"t_orders\".\"id\", \"t_orders\".\"order_name\", \"t_orders\".\"created_on\" order by \"t_orders\".\"id\" ASC",
"bindings": [
"2022-10-11"
]
}
}
}