interday_tick_qry1.sql

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

Output

The results of this query are:

TRADING_SYMBOL   VOLUME_WEIGHTED_PRICE
AAA                   49.6641081572369
Note:

The output displayed in this section is derived by running the query with the large set of sample data provided in the Sybase RAP Samples component.

SQL Statements

These are the SQL statements for this query.

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

commit;

SELECT TRADING_SYMBOL,
SUM(TRADE_SIZE*TRADE_PRICE)/SUM(TRADE_SIZE) as VOLUME_WEIGHTED_PRICE
FROM STOCK_TRADE
WHERE TRADE_DATE BETWEEN '2005-11-10'
AND '2005-11-14'
AND TRADING_SYMBOL ='AAA'
GROUP BY TRADING_SYMBOL;


Created March 26, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com