I have two tables with firstname, lastname and amount.
I can do a left join:
select * from spi left join dp
on spi.amount = dp.amount
and lower(spi.firstname) = lower(dp.firstname)
and lower(spi.lastname) = lower(dp.lastname);
which gives good results:
|# |firstname |lastname |amount|dp.firstname |dp.lastname |dp.amount
|----+--------------+------------+------+-------------+-------------+---------
|1 |saumeh synah |s***** |50.0 | | |
|2 |Neda |M***** |1000.0| | |
|3 |Mansoor |B********** |100.0 | | |
|4 |Hanna |W**** |50.0 |Hanna |W**** |50.0
|5 |Kristen |A**** |40.0 |Kristen |A**** |40.0
|6 |David |B****** |10.0 |David |B****** |10.0
Now I want to select just the rows that are missing from dp.
So I write:
select * from (
select * from spi left join dp
on spi.amount = dp.amount
and lower(spi.firstname) = lower(dp.firstname)
and lower(spi.lastname) = lower(dp.lastname) )
where dp.amount = null;
but I get the error
no such column: dp.amount
Why not?
The error is due to the derived table. Just try a simple query: