straightforward logic but did not pass 3/9 test cases. not sure why? Could someone help?


  • 0
    C
    select A.question_id as survey_log from
    
        (select SL1.question_id, count(SL1.action) as numA from survey_log SL1
        where SL1.action='answer'
        group by SL1.question_id) A join
        (select SL2.question_id, count(SL2.action) as numS from survey_log SL2
        where SL2.action='show'
        group by SL2.question_id) S
        on A.question_id=S.question_id
        order by (numA/numS) desc
        limit 1
    

  • 0
    A
    This post is deleted!

  • 0
    A

    The test case 3 doesn't have any record with the action as show. Due to this, the inner query with action='show' return no records. Hence the join won't happen as it is an inner query.

    You can try removing the filter action='show' from the inner query.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.