tick_qry2.sql

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

Output

The result of this query for the security ADV is:

TRADING_SYMBOL    VOLUME_WEIGHTED_PRICE
ADV                         30.73768473

Historical Database Script

-- 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;

In-Memory Database Script

-- 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