asked on
SELECT SYMBOL, PRICE, SELLBROKER, TRADETIMESTAMP
FROM dbname.TRADES
WHERE SYMBOL IN ( SELECT DISTINCT SYMBOL
FROM dbname.TRADES
WHERE PREVIOUSTICKDIRECTION < 1
GROUP BY SYMBOL
HAVING COUNT(SELLBROKER) > 3)
ORDER BY SYMBOL, timestamp(TRADETIMESTAMP) ASC;
ASKER
SELECT T.SYMBOL
,T.PRICE
,T.SELLBROKER
,T.TRADETIMESTAMP
FROM dbname.TRADES T
INNER JOIN
(
SELECT DISTINCT SYMBOL
FROM dbname.TRADES
WHERE PREVIOUSTICKDIRECTION < 1
GROUP BY SYMBOL
HAVING COUNT(SELLBROKER) > 3
) T2 ON T.SYMBOL = T2.SYMBOL
ORDER BY T.SYMBOL
,TIMESTAMP(T.TRADETIMESTAMP) ASC;
SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.
TRUSTED BY
ASKER
I will be running all this in a stored procedure. So I DO have the option of firing the subselect query, parsing it out into a comma delimited list and putting it into the other query. However, this seems ridiculous given the fact of how mature of a product mySQL is. Do you have any other suggestions? (I will give you partial points when all is said and done, since yours indeed does work better)