Output  setup_tick_qry3_last_price.sql

Appendix A: SQL Scripts for Sample Queries

SQL

The following script contains the SQL statements for this query. Note that there are separate scripts optimized for the RAP cache and the RAP repository.

RAP repository

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

RAP cache

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




Copyright © 2005. Sybase Inc. All rights reserved. setup_tick_qry3_last_price.sql

View this book as PDF