CCL Expressions in the SELECT Clause

The SELECT clause may contain a list of one or more columns, which are published to the destination stream specified in the INSERT INTO clause. Each of the items in the select list may also be an expression.

While select list expressions typically reference column names, they are not limited to column names, and may not contain column names at all.

Select list expressions may include one or more of the expression elements listed in the previous sections. An item in the select list may be a simple literal, column name or a complex expression containing a mix of literals, column names, operators and functions.

Here is an example of an expression used in a select list. This query publishes the total dollar amount for each trade, and the trade identification number associated with the trade, to the TradeValues stream:

INSERT INTO TradeValues(id, tradevalue) 
SELECT tradeid, volume*price 
FROM StockTrades;

The TradeValues stream has the following schema:

Column

Datatype

Description

id

String

A unique sequence number that identifies each trade.

commission

Float

The commission value of this trade.

tradevalue

Float

The total value of this trade (volume * price).

Note the following important points about this query:


Here is an example of what the input and output streams would look like for this query:




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