Here is a very generic but (almost) everything covering select
SELECT t1.col_1
,col_2 as column2
,t4.col_3 * (4+2)
,t2.col_4 +2 as column_4_plus_2
,Concat(a,b,c,d) as my_sql_func
,count((select foo from bar where something is ture)) as sub_query_column
,custom_function(a,b,2)
FROM t1
,t2 t4
LEFT OUTER JOIN t3 as t5 ON t3.id = t1.id
,(select foo from bar where something is ture) as sub_query_table
WHERE (t1.col_1 like '% something %' OR (col_2=3 and t2.col_4='hello world'))
AND NOT EXISTS (select foo from bar b where b.id = t1.id)
GROUP BY t1.col_1, col_2, t4.col_3 * (4+2), t2.col_4 +2
HAVING count(*) > 3
ORDER BY t1.col_1 DESC
LIMIT 100;
The following statements are causing problems:
1) count((select foo from bar where something is not null)) as sub_query_column
This is completly legal.
On mysql test:
mysql> select now(), count((select now() from dual)) from dual;
+---------------------+---------------------------------+
| now() | count((select now() from dual)) |
+---------------------+---------------------------------+
| 2012-10-02 19:06:01 | 1 |
+---------------------+---------------------------------+
1 row in set (0.01 sec)
On Oracle XE:
SQL> select 'a', count((select 'a' from dual)) from dual;
' COUNT((SELECT'A'FROMDUAL))
- --------------------------
a 1
2) subselect in from
,(select foo from bar where something is ture) as sub_query_table