Sample Header Ad - 728x90

SQL query does not recognise derived table

0 votes
1 answer
1029 views
So I've made a simple SQL query: SELECT companyname FROM works w1, ( SELECT companyname,sum(salary) AS sumsal FROM works GROUP BY companyname ) w2 WHERE w1.companyname=w2.companyname it works fine so far but then I add the following line in the where clause: AND w2.sumsal=(SELECT MIN(w2.sumsal) FROM w2); I get: ERROR 1146 (42S02): Table 'companydb.w2' doesn't exist I'm using MySQL 8.0.
Asked by mrmagin (3 rep)
Oct 28, 2018, 02:35 PM
Last activity: Oct 29, 2018, 10:43 AM