Snowflake: Unsupported subquery for DISTINCT - Column order matters?

前端 未结 2 1436
鱼传尺愫
鱼传尺愫 2021-01-16 00:16

I have two related tables (unnecessary columns not listed):

LOCATION

VENUE_ID - NUMBER(38,0)

VISIT

         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-16 00:43

    I think you're making this more complex than this needs to be. Below should be all you need:

    SELECT l.venue_id
      , count(distinct v.device_id)
    FROM location l
    LEFT JOIN visit v
     on l.venue_id = v.venue_id
    GROUP BY l.venue_id
    

提交回复
热议问题