SQL subquery with COUNT help

前端 未结 4 1698
挽巷
挽巷 2021-02-01 13:41

I have an SQL statement that works

SELECT * FROM eventsTable WHERE columnName=\'Business\'

I want to add this as a subquery...

         


        
4条回答
  •  别那么骄傲
    2021-02-01 14:08

    SELECT e.*,
           cnt.colCount 
    FROM eventsTable e
    INNER JOIN (
               select columnName,count(columnName) as colCount
               from eventsTable e2 
              group by columnName
               ) as cnt on cnt.columnName = e.columnName
    WHERE e.columnName='Business'
    

    -- Added space

提交回复
热议问题