In the former the $registered_sql is a aql. So it will be executed as a sub query for every row.
But in the latter $registered_sql is not a sql. CActiveRecord::count() doesn’t return a sql string, but the count number itself as a string.
It’s just a count of rows whose cSchulungsTerminID is something that you have in $this->cSchulungsTerminID. Note that $this refers to the model that has the search parameters. When you do not specify cSchulungsTerminID in the search, then $this->cSchulungsTerminID should be empty, and you’ll get “0” for the $registered_sql.