SQL Query working differently in playground vs SDK
Hi (again),
I have the following code:
And the result of that query is
But, in the playground, I run the same query:
And then I get
Is there anything I may be doing wrong in here?
Thanks!!
I have the following code:
const subquery = `SELECT DISTINCT (o.id)
FROM transactions t,
orders o
WHERE t.report = '${report_id}'
AND t.order = o.id`;
const total_amounts = await this.dbClient.sql<{
total_invoiced: number,
total_commission: number;
}>`SELECT SUM(orders.total_price) AS total_invoiced, SUM(orders.total_commission) AS total_commission
FROM orders
WHERE orders.id in (${subquery})`;const subquery = `SELECT DISTINCT (o.id)
FROM transactions t,
orders o
WHERE t.report = '${report_id}'
AND t.order = o.id`;
const total_amounts = await this.dbClient.sql<{
total_invoiced: number,
total_commission: number;
}>`SELECT SUM(orders.total_price) AS total_invoiced, SUM(orders.total_commission) AS total_commission
FROM orders
WHERE orders.id in (${subquery})`;And the result of that query is
{
records: [ { total_commission: null, total_invoiced: null } ],
rows: undefined,
warning: undefined,
columns: [
{ name: 'total_invoiced', type: 'float8' },
{ name: 'total_commission', type: 'float8' }
]
}{
records: [ { total_commission: null, total_invoiced: null } ],
rows: undefined,
warning: undefined,
columns: [
{ name: 'total_invoiced', type: 'float8' },
{ name: 'total_commission', type: 'float8' }
]
}But, in the playground, I run the same query:
SELECT SUM(orders.total_price) AS total_invoiced, SUM(orders.total_commission) AS total_commission
FROM orders
WHERE orders.id in (SELECT DISTINCT (o.id)
FROM transactions t,
orders o
WHERE t.report = 'rec_REDACTED'
AND t.order = o.id)SELECT SUM(orders.total_price) AS total_invoiced, SUM(orders.total_commission) AS total_commission
FROM orders
WHERE orders.id in (SELECT DISTINCT (o.id)
FROM transactions t,
orders o
WHERE t.report = 'rec_REDACTED'
AND t.order = o.id)And then I get
{
"records": [
{
"total_commission": 2271.84,
"total_invoiced": 28398
}
],
"columns": [
{
"name": "total_invoiced",
"type": "float8"
},
{
"name": "total_commission",
"type": "float8"
}
],
"total": 0
}{
"records": [
{
"total_commission": 2271.84,
"total_invoiced": 28398
}
],
"columns": [
{
"name": "total_invoiced",
"type": "float8"
},
{
"name": "total_commission",
"type": "float8"
}
],
"total": 0
}Is there anything I may be doing wrong in here?
Thanks!!
