A
amerar
Ok, I should be able to figure this out, but guess not.
I have a long string here, and I'm using the INDEX function to find a
string within that. Why then, is it always returning the wrong
position??? Here are some examples. I'm looking for the string "
AND ", notice the capital letters.
Here is my INDEX statement:
for $i (0 .. $#info) {
$customer_id = $info[$i][0];
$screen_name = $info[$i][1];
$screen_query = substr($info[$i][2],4);
$and = index($screen_query, 'AND');
print "AND POSITION IS HERE: $and\n";
}
POSITION IS HERE: 8
HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
master_table.ticker,master_table.comp_name,DIV_YIELD,NET_MARGIN,DEBT_TO_EQUITY,PRICE_TO_BOOK,PRICE_TO_CASH,PRICE_TO_SALES
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND
upper(PRICE_TO_BOOK) <= 1.2 AND upper(PRICE_TO_CASH) >= 1.5 AND
upper(PRICE_TO_SALES) <= 1.2
POSITION IS HERE: 38
HERE: 20,1115|select master_table.ticker,master_table.comp_name from
master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND upper(DIV_YIELD)
POSITION IS HERE: 381
HERE:
16\1020,1021,1024,1028,1115,1030,1032,1033,1040,1042,1055,1056,1057,1065,1073,1078|
select
master_table.ticker,stock_data.EXCHANGE,stock_data.SECTOR_NAME,stock_data.MKT_VALUE,master_table.comp_name,prices.CLOSING,stock_data.HIGH_52W,stock_data.LOW_52W,daily_zacks_rank.z_rank_d,AVG_RATING,Q_EST_SURP,SURP_PREV,SURP_AVG_4Q,NET_PERC_INS,TREND_EPGR,PE_12M
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker(+) AND
upper(daily_zacks_rank.z_rank_d) <= 2 AND upper(AVG_RATING) <= 2 AND
upper(Q_EST_SURP) >= 0 AND upper(SURP_PREV) >= 0 AND
upper(SURP_AVG_4Q) >= 0 AND upper(stock_data.MKT_VALUE) >= 500 AND
upper(stock_data.PERC_CHG_12W) >= 10 AND upper(PRICE_TO_SALES) <= .5
Go figure???
I have a long string here, and I'm using the INDEX function to find a
string within that. Why then, is it always returning the wrong
position??? Here are some examples. I'm looking for the string "
AND ", notice the capital letters.
Here is my INDEX statement:
for $i (0 .. $#info) {
$customer_id = $info[$i][0];
$screen_name = $info[$i][1];
$screen_query = substr($info[$i][2],4);
$and = index($screen_query, 'AND');
print "AND POSITION IS HERE: $and\n";
}
POSITION IS HERE: 8
HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
master_table.ticker,master_table.comp_name,DIV_YIELD,NET_MARGIN,DEBT_TO_EQUITY,PRICE_TO_BOOK,PRICE_TO_CASH,PRICE_TO_SALES
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND
upper(PRICE_TO_BOOK) <= 1.2 AND upper(PRICE_TO_CASH) >= 1.5 AND
upper(PRICE_TO_SALES) <= 1.2
POSITION IS HERE: 38
HERE: 20,1115|select master_table.ticker,master_table.comp_name from
master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND upper(DIV_YIELD)
= 4 AND upper(DEBT_TO_EQUITY) <= .2
POSITION IS HERE: 381
HERE:
16\1020,1021,1024,1028,1115,1030,1032,1033,1040,1042,1055,1056,1057,1065,1073,1078|
select
master_table.ticker,stock_data.EXCHANGE,stock_data.SECTOR_NAME,stock_data.MKT_VALUE,master_table.comp_name,prices.CLOSING,stock_data.HIGH_52W,stock_data.LOW_52W,daily_zacks_rank.z_rank_d,AVG_RATING,Q_EST_SURP,SURP_PREV,SURP_AVG_4Q,NET_PERC_INS,TREND_EPGR,PE_12M
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker(+) AND
upper(daily_zacks_rank.z_rank_d) <= 2 AND upper(AVG_RATING) <= 2 AND
upper(Q_EST_SURP) >= 0 AND upper(SURP_PREV) >= 0 AND
upper(SURP_AVG_4Q) >= 0 AND upper(stock_data.MKT_VALUE) >= 500 AND
upper(stock_data.PERC_CHG_12W) >= 10 AND upper(PRICE_TO_SALES) <= .5
Go figure???