INVOICE ( INV_NUM, CUST_NUM, INV_AMOUNT) (the existing columns that are used)
I'm working on learning SQL from Oracle's website and a book I bought. I want to build a query that will show INV_NUM, INV_AMOUNT.
Along with that I want it to show two more columns derived from the AVG of the INV_AMOUNT column. That will be called INV_AVG
I also want the difference shown between INV_AVG and INV_AMOUNT, that will be called INV_DIFF
Below are the individual statements I created...but now I have to combine it all together into one statement.
SELECT INV_NUM, INV_AMOUNT
SELECT AVG(INV_AMOUNT) as INV_AVG
SELECT INV_AVG - INV_AMOUNT
I know I have to be way off, but I was thinking something along the lines of:
SELECT INV_NUM, INV_AMOUNT, INV_AVG, INV_DIFF
WHERE INV_DIFF = INV_AVG - INV_AMOUNT AND INV_AMOUNT = AVG(INV_AMOUNT)
Any ideas where to start?