I am working on Spark SQL using Scala. I have a requirement where i need to divide the count from two queries.
Query 1 - select count(1) from table_1 where flag = 'Y'
Query 2 - select count(1) from table_2 where flag = 'N'
Now, I need to divide count from query 1 and query 2.
val divideValue = sqlContext.sql("
SELECT count(*) FROM table_1 where y != 'yes'/SELECT count(*) FROM table_2 where y = 'yes'
")
The above doesn't work. Please suggest with the actual query