Queries to verify billing integritiy

select sum(Total) from Bills where NewBillId is not null and VatAccountId=1 and Status in (3,4) and CreatedOn >= '2025-01-01' and CreatedOn < '2026-01-01';

select sum(Total) from Bills where id in (select NewBillId from Bills where NewBillId is not null and VatAccountId=1 and Status in (3,4) and CreatedOn >= '2025-01-01' and CreatedOn < '2026-01-01') and status in (1,2);

select sum(EndCounter-StartCounter) from AircraftLogs where id in ( select AircraftLogId from Transactions where billid in ( select id from Bills where NewBillId is not null and VatAccountId=1 and Status in (3,4) and CreatedOn >= '2025-01-01' and CreatedOn < '2026-01-01'));

select sum(Quantity) from Transactions where BillId in (select ID from Bills where NewBillId is not null and VatAccountId=1 and Status in (3,4) and CreatedOn >= '2025-01-01' and CreatedOn < '2026-01-01') and AircraftLogId is not null and ArticleId <> 10;

select sum(Quantity) from Transactions where BillId in ( select id from Bills where id in (select NewBillId from Bills where NewBillId is not null and VatAccountId=1 and Status in (3,4) and CreatedOn >= '2025-01-01' and CreatedOn < '2026-01-01') and status in (1,2)) and AircraftLogId is not null and ArticleId <> 10;

select sum(mx-mn) from (select max(EndCounter) as "mx", min(StartCounter) as "mn",Aircrafts.CallSign from AircraftLogs left join Aircrafts on AircraftLogs.AircraftId = Aircrafts.Id where DepartureTime >= '2025-01-01' and DepartureTime < '2026-01-01' and AircraftId <> 1488 and AircraftId <> 3318 and AircraftId <> 72 and AircraftId <> 73 group by Aircrafts.CallSign) as q1;

select max(EndCounter) as "mx", min(StartCounter) as "mn",Aircrafts.CallSign from AircraftLogs left join Aircrafts on AircraftLogs.AircraftId = Aircrafts.Id where DepartureTime >= '2025-01-01' and DepartureTime < '2026-01-01' and AircraftId <> 1488 and AircraftId <> 3318 and AircraftId <> 72 and AircraftId <> 73 AND FlightActivityTypeId in (1,7,11) group by Aircrafts.CallSign;

select sum(EndCounter-StartCounter) as "qt",Aircrafts.CallSign from AircraftLogs left join Aircrafts on AircraftLogs.AircraftId = Aircrafts.Id where DepartureTime >= '2025-01-01' and DepartureTime < '2026-01-01' and AircraftId <> 1488 and AircraftId <> 3318 and AircraftId <> 72 and AircraftId <> 73 AND FlightActivityTypeId in (1,7,11) group by Aircrafts.CallSign order by qt desc;

SELECT Aircrafts.CallSign, COUNT() "NbDiffs", SUM(Transactions.Quantity) "Billded", SUM(AircraftLogs.EndCounter-AircraftLogs.StartCounter) "AircraftLogTotal" -- SELECT Aircrafts.CallSign, Bills.Id ,Transactions. , (AircraftLogs.EndCounter-AircraftLogs.StartCounter) "AircraftLogTotal" -- SELECT AircraftLogs.* From Transactions left join AircraftLogs on AircraftLogs.Id = Transactions.AircraftLogId left join Aircrafts on Aircrafts.id = AircraftLogs.AircraftId -- left join ArticlePrices on Transactions.ArticlePriceId = ArticlePrices.Id inner join Bills on Transactions.BillId = Bills.Id where AircraftLogs.AircraftId <> 1488 and AircraftLogs.AircraftId <> 3318 and AircraftLogs.AircraftId <> 72 and AircraftLogs.AircraftId <> 73 and Transactions.Quantity <> (AircraftLogs.EndCounter-AircraftLogs.StartCounter) and FlightActivityTypeId in (1,7,11) and DepartureTime >= '2025-03-01' and DepartureTime < '2026-01-01' and Bills.Status in (1,2) -- and AircraftLogs.Id = 22762 and Transactions.ArticleId IN (11,12) -- and ArticlePrices.ArticleId IN (11,12) order by AircraftLogs.id desc

-- group by Aircrafts.CallSign

Flying Fleet
Contact us for more information or to book a live demo.
Flying Fleet is a Redcrest Solutions product.

+41 41 511 50 99
Redcrest Solutions GmbH
Sinserstrasse 67
6330 Cham Switzerland
2026 Flying Fleet. All rights reserved.

We use cookies

We use cookies and similar tracking technologies to enhance your browsing experience and gather statistical data. To help us develop and improve our content and services, we may securely store or access information on your device and process personal data, such as your IP address and browsing history. Our primary analytics tool is Google Analytics. Please note that the cookies we use are essential for the website to function correctly.
Accept