-1

How to run the outer query with out any issues.

SELECT DISTINCT TOP (100) PERCENT NBR, Customers, status
FROM (
  SELECT  NBR, Customers, Code AS status
  FROM   CCC AS CS 
  INNER JOIN AAA AS AC ON CCC.B2= ACT.B1 AND CSS.B2 = ACT.B1
) AS rst
WHERE status IN ('A', 'T')

Update

Thanks for your response, I need percent of top 100 records, can I know how do I use the percent here in the query.

SELECT PERCENT NBR, Customers, status 
FROM ( 
    SELECT NBR, Customers, Code AS status 
    FROM CCC AS CS 
    INNER JOIN AAA AS AC 
        ON CCC.B2= ACT.B1 AND CSS.B2 = ACT.B1 
)AS rst 
WHERE status IN ('A', 'T') )
ORDER BY NBR LIMIT 100
d.hoeffer
  • 592
  • 3
  • 13
Akhira
  • 203
  • 2
  • 5
  • 16
  • 1
    Please do not post multiple copies of you questions, eg https://stackoverflow.com/questions/59218213/how-to-use-the-percent-key-word-in-the-snowflake-query (How to use the percent key word in the snowflake query) – Hans Henrik Eriksen Dec 06 '19 at 19:21

1 Answers1

1

That query doesn't need a subquery, but I believe it would work if you weren't using a TOP (100) PERCENT in there. That isn't the right syntax for Snowflake. You need to use a LIMIT. Although, if you are asking for 100%, then not sure why you are using a TOP at all.

If you have a specific error message that'd help, but in your case, it's not the subquery that is likely affecting you.

Mike Walton
  • 6,595
  • 2
  • 11
  • 22