TPC-DI AQ3
TPC-DI benchmark · all TPC-DI queries
Representative SQL
Rendered for DataFusion with default parameters.
SELECT 'Broker Performance Analysis' AS analysis_name, b.FirstName || ' ' || b.LastName AS broker_name, b.Branch, b.Office, COUNT(DISTINCT t.SK_CustomerID) AS unique_customers, COUNT(t.TradeID) AS total_trades, SUM(t.Quantity) AS total_quantity_traded, SUM(t.Quantity * t.TradePrice) AS total_trade_value, SUM(t.Commission) AS total_commission_generated, AVG(t.Commission) AS avg_commission_per_trade, AVG(t.TradePrice) AS avg_trade_price, SUM(t.Commission) / SUM(t.Quantity * t.TradePrice) * 100 AS commission_rate_pct, COUNT(t.TradeID) / COUNT(DISTINCT t.SK_CustomerID) AS trades_per_customer, SUM(t.Quantity * t.TradePrice) / COUNT(DISTINCT t.SK_CustomerID) AS value_per_customer, COUNT(CASE WHEN tt.TT_IS_SELL IS TRUE THEN 1 END) AS sell_trades, COUNT(CASE WHEN tt.TT_IS_SELL IS FALSE THEN 1 END) AS buy_trades, COUNT(CASE WHEN tt.TT_IS_SELL IS TRUE THEN 1 END) / COUNT(t.TradeID) * 100 AS sell_ratio_pctFROM DimBroker AS bLEFT JOIN FactTrade AS t ON b.SK_BrokerID = t.SK_BrokerIDLEFT JOIN TradeType AS tt ON t.Type = tt.TT_IDLEFT JOIN DimDate AS d ON t.SK_CreateDateID = d.SK_DateIDWHERE b.IsCurrent IS TRUE AND ( d.CalendarYearID >= 2015 AND d.CalendarYearID <= 2019 ) AND t.Status = 'Completed'GROUP BY b.FirstName, b.LastName, b.Branch, b.OfficeHAVING COUNT(t.TradeID) > 10ORDER BY total_commission_generated DESC, total_trade_value DESCLIMIT 50Representative DataFrame
No DataFrame implementation is registered for this query.
Get the exact query for your run
The blocks above are representative. To get the precise statement a specific platform runs at a specific scale, substitute your own values:
from benchbox import TPCDI
bench = TPCDI(scale_factor=0.01) # your scale factorqueries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQLprint(queries['AQ3'])Source
Query text: benchbox/core/tpcdi/query_analytics.py