QuestionQ2

Prepare and process data

You have an Azure Databricks workspace enabled for Unity Catalog that contains two Delta tables, Table1 and Table2, with the same data type.

Table1 has a column named Column1. Table2 has a column named Column2.

You execute the following query:

SELECT Colum1 -  
  
FROM Table1 -  
  
GROUP BY Column1 -  
  
HAVING COUNT(*) > 1 -  
  
INTERSECT -  
  
SELECT Column2 -  
  
FROM Table2 -  
  
GROUP BY Column2 -  
HAVING COUNT(*) > 1;  

What happens when the query is executed?

  • A Values appear in both tables more than once.
  • B Values appear in either table more than once.
  • C Values appear in Table2 but NOT Table1.
  • D Values appear in Table1 more than once.
Explanation

GROUP BY with HAVING COUNT(*) > 1 returns only values that occur more than once in each table. INTERSECT retains only rows common to both result sets, so the result contains values that appear more than once in both tables. Azure Databricks documents that only rows common to the two operands are returned by INTERSECT.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!