Sort table with quarry

Discuss the database features
Post Reply
senaka
Posts: 5
Joined: Fri Dec 08, 2017 1:47 am

Sort table with quarry

Post by senaka »

Hi all,
i just get in to this world, i apologize all mistake i might do.

i have tow tables, one

ID order Qty
1 500 1
2 500-1 2
3 400 1

2nd table

order_id status
500 ok
500-1 ok
500-1 ok
400 ok

i wanna wright quarry how many qty finish from table one. table tow get information out of scanning. if you see table tow i have tow rows 500-1 because of tow Qty, wen i wanna see result i would line to see how many Qty done so far.

Thank you in advanced.
Windows 7 64-bit
open office 4.1.4
UnklDonald418
Volunteer
Posts: 1548
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: sort table with quarry

Post by UnklDonald418 »

Welcome to the the forum.
Sorry but the structure of your tables isn't clear, but it appears you want to generate a running total. That requires a sub query something like

Code: Select all

SELECT "TA"."ID", "TA"."Qty"
, (SELECT SUM("S"."QTY") FROM "TableA" AS "S" WHERE "S"."ID" <= "TA"."ID")  AS "Running Total" 
FROM "TableA" AS "TA"
If you need further help with this please upload a sample database.
viewtopic.php?f=74&t=8289
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply