SQL

The following script contains the SQL statements for this query. Note that there are separate scripts optimized for RAPCache and VLDBServer.

VLDBServer

-- Determine the volume weighted price of a security considering
-- only the ticks in a specified three hour interval.

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

commit
;

SELECT TRADING_SYMBOL,
SUM(TRADE_SIZE*TRADE_PRICE)/SUM(TRADE_SIZE) as VOLUME_WEIGHTED_PRICE
FROM STOCK_TRADE
WHERE TRADE_TIME BETWEEN '2005-11-14 12:00'
AND '2005-11-14 15:00'
AND TRADING_SYMBOL ='ADV'
GROUP BY TRADING_SYMBOL;

RAPCache

-- Determine the volume weighted price of a security considering
-- only the ticks in a specified three hour interval.

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


SELECT TRADING_SYMBOL,
SUM(TRADE_SIZE*TRADE_PRICE)/SUM(TRADE_SIZE) as VOLUME_WEIGHTED_PRICE
FROM STOCK_TRADE
WHERE TRADE_TIME BETWEEN '2005-11-14 12:00' AND '2005-11-14 15:00'
AND TRADING_SYMBOL = 'ADV'
GROUP BY TRADING_SYMBOL

go