I have a table containing transaction details which I am importing from several vendor-provided daily reports.. I want to be sure that I am not skipping any of the files (one file per day) as I do this process..
So I wanted to query the database to find the number of distinct dates it found in the result set.
At first I tried to execute:
SELECT COUNT(t.*) FROM (SELECT DISTINCT `Date of Survey` from cc.voc_detail_old) t;
But that generates the error "* SQL Error (1064): You have an error in your SQL syntax;..."
Changing it to SELECT Count(*)...
resolves the error and the query functions as expected. Why is it not permissible to use the alias of the derived table in the Count()
function, but the derived table's alias is required per syntax?
Count(DISTINCT...)
:-)