FALCONSEYE
Programmer
What is the equivalent of the following t-sql statement?
select count(1)
from myTable
where count(1) < 10
select count(1)
from myTable
where count(1) < 10
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
select count(1)
from myTable
where count(1) < 10;
no rows selected
select count(1)
from s_emp
[B][I]HAVING[/I][/B] count(1) < 10
/
no rows selected
Surely that depends on the number of rows in [tt]myTable[/tt]. If it has less than ten rows, you get a result; if it doesn't, you don't:in its current form, the code doesn't return anything
SQL> SELECT COUNT(1)
2 FROM dual
3 HAVING COUNT(1) < 10
4 /
COUNT(1)
----------
1
SQL> SELECT COUNT(1)
2 FROM all_objects
3 HAVING COUNT(1) < 10
4 /
no rows selected
select count(1) as appCountByIP
from myLogTable
where ipAddress = '1.1.1.1'
and count(1) > 1
select count(1) as appCountByIP
from myLogTable
where ipAddress = '1.1.1.1'
having count(1) > 1
Server: Msg 147, Level 15, State 1, Line 1
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
Any rain that clears the skies is welcome. (I was wondering how SQL Server could process an aggregate function in a WHERE clause.)Yelworcm said:Not to rain on the parade...