我的问题是如何从查询结果中删除负值。我的sql查询返回正值和负值。我只想要前10个正数。但我不知道如何从结果集中删除负数
这是我的问题:
SELECT (select account_name from mk_account_master where account_id = atm.account) as account,sum(debit)-sum(credit) as balance,(select Branch_name from mk_branch_master where Branch_id = atm.books) as branch_name from mk_account_transaction_master as atm where account in (SELECT account_id from mk_account_master where type = 'contractor') GROUP BY account,books limit 10
查询结果:
account balance branch_name
CTA-test@vendor-8761239088 -1320.00 Anthiyur Colony-Erode-Tamil Nadu-1
CTA-test@vendor-8761239088 -1200.00 raj_New@project_Anthiyur_3
CTA-test@vendor-8761239088 -1200.00 raj_Erode_Anthiyur_4
CTA-test@vendor-8761239088 +1500.00 raj_Erode_Anthiyur_5
答案 0 :(得分:0)
试试这个:
SELECT Balance(field) FROM table WHERE Balance >= 0
答案 1 :(得分:0)
您的查询似乎很复杂。您可以使用JOINS使其易于阅读和优化