Hive query to check mathematical values from multiple tables
Hi all,
I'm looking to create a query to check and validate the math on certain fields from different tables. I've found examples where the SUM function was used- but I struggled putting it together, and am just trying to find the best way to do these calcuations.
Sample data:
Customer table:
| Customer ID | Money Spent |
| 0001 | 500 |
| 0002 | 250 |
| 0003 | 100 |
Sales table:
| Order ID | Amount |
| 5005 | 500 |
| 5006 | 250 |
| 5007 | 50 |
Check sales math work in progress query(the query doesn't seem to work, returns a "delta" column with a {null} result:
SELECT
CAST(SUM(Customer.Money Spent - Sales.Amount) AS INT) AS DELTA
The desired output that I'd like:
Check table
| Rule Name | Delta |
| Sales Check | 0 |
| Sales Check | 0 |
| Sales Check | 50 |
Thanks in advance,

