tick_qry4.sql

Determines the top 10 most active stocks for a specified date, sorted by cumulative trade volume, by considering all trades.

Output

The rows returned by this query are:

TRADING_SYMBOL    TRADESIZE
AJC                 269100
AWO                 250900
ASZ                 249000
AHI                 230600
AKX                 225600
AKD                 222000
AZO                 221200
BED                 220300
AMW                 219400
AQD                 219100

Historical Database Script

-- Determine the top 10 most active stocks for a specified date
-- sorted by cumulative trade volume by considering all trades.


-- This query is optimized to run on IQ.

commit
;

SELECT TOP 10 TRADING_SYMBOL, sum(TRADE_SIZE) as TRADESIZE, DENSE_RANK ()
OVER (ORDER BY sum(TRADE_SIZE) DESC) as RANKING
	FROM STOCK_TRADE
WHERE  	TRADE_DATE = '2005-11-14' 
	GROUP BY TRADING_SYMBOL
	order by sum(TRADE_SIZE) DESC
;

In-Memory Database Script

-- Determine the top 10 most active stocks for a specified date
-- sorted by cumulative trade volume by considering all trades.

-- This query will run on either the ASE or IQ platform.

set  rowcount 10
go

SELECT TRADING_SYMBOL, sum(TRADE_SIZE) as TRADESIZE
	FROM STOCK_TRADE
WHERE
TRADE_TIME between '2005-11-14 00:00:00'  and '2005-11-14 23:59:59'
GROUP BY TRADING_SYMBOL
order by sum(TRADE_SIZE) DESC
go
set rowcount 0
go