| Welcome to WebmasterWorld Guest from 220.127.116.11 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Pubcon Platinum Sponsor 2014|
|How to query Sub-queries in same table.|
can i do this?
SELECT * FROM transactions as t1 WHERE TotalAmount < (SELECT SUM(t2.TotalAmount) FROM transactions as t2 WHERE t1.TransactID = t2.TransactRefID) ORDER BY ActualDate DESC;
does it work? as i tested, no error.. but no result to.. all i know, it should have a results...
can anybody answer me please? please help..
First of all you dont need to add t1,t2. We name the tables as t1,t2....if there are more then 1 table.
try removing t1 and t2 and then fire the query.
SELECT * FROM transactions WHERE TotalAmount < (SELECT SUM(TotalAmount) FROM transactions WHERE TransactID = TransactRefID) ORDER BY ActualDate DESC
Let me know if it works or not
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved