I do have one table with 2 columns and another with 2 columns
employee(id, transaction_date),
employee_1(id, transaction_date)
Below is the query i tried, but it’s returning an error
SELECT COUNT(DISTINCT id) / COUNT(DISTINCT id) FROM employee, employee_1
Error is
SQL Error [2028] [42601]: SQL compilation error:
ambiguous column name 'id'
Can anyone help me with this?
2
Answers
You need to make the column reference unique. This is done with a table alias or the initial table name in front of the columnname: https://docs.snowflake.com/en/sql-reference/constructs/from.html
or
From performance perspective using
CROSS JOIN
is suboptimal. This pattern is called “Exploding” Joins:A better approach is to use indepenedent queries and secure against division by zero:
or