I need to do:
SELECT COUNT(*)
FROM some_table
WHERE someAlias1 = someValue1
AND someAlias2 = someValue2;
someAlias is an alias for a column in some_table. In my case I can’t name the columns directly; I need to use aliases.
The issue is that I only know about defining aliases inside the select clause which I don’t see how I can do in this case.
Is there a way to accomplish what I need in this case?
edit: Why do I need aliases? I’m building a query from alternative parts, and the condition above applies to different columns from different tables, but with the same logical role. So I need a way to relate to different alternative columns with the same name.
I will appreciate if you answer this question only if you know an answer, even if you don’t understand why may I need an alias
You could do a nested SELECT statement then draw the count out from the inner query, I don’t really see a way to escape using the column names