Selecting Rows and Columns

One of the most important functions of a CCL query is to select which rows and columns are passed from the source stream to the destination stream. Columns are selected by specifying the required columns in the Select list.

Rows are selected by using one or more filter or selection conditions. A row is selected if all of the filter conditions are true.

Let's look at a slightly more complex query which illustrates column and row selection:

INSERT INTO StockTradesMicrosoft 
SELECT volume, price 
FROM StockTrades 
WHERE symbol = 'MSFT';

In this example, only the volume and price data is needed, so the destination stream StockTradesMicrosoft has the following schema:

Column Datatype Description
shares Integer The number of shares exchanged for this trade.
price Float The price of each share exchanged for this trade.

The query selects the volume and price columns (SELECT volume, price) from the StockTrades stream for all Microsoft stock trades (WHERE symbol = 'MSFT'). Notice the following syntax in 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