我有以下账单表
building flatname flatdescription amount pastpayments receiptno
1234 name a a 123 0 0
1234 name a a 12 10 39
1234 name a a 125 125 40
1235 name a a 133 10 41
1235 name b b 125 125 50
1234 name c c 100 90 0
我想使用建筑代码 1234 选择金额减去付款大于零的行,如果同名中的收据编号 > 0,则以样式 b 显示它们,如果同名中没有收据编号 > 0,则不显示样式
所以我的代码的结果必须如下
name a 39 with style B
name c 0
我怎样才能做到这一点?
我使用以下代码,但我收到所有没有样式的选择
t.executeSql('SELECT receiptno AS mr, flatdescription, flatname, buildingcode FROM bill WHERE amount - pastpayments> 0 AND buildingcode = ? GROUP BY buildingcode, flatname ORDER BY flatdescription DESC',[buildingcode], function(t, resultflat) {
var i,
len = resultflat.rows.length,
row;
if (len > 0 ) {
items.push('<br>');
for (i = 0; i < len; i += 1) {
row = resultflat.rows.item(i);
if (row.mr > 0) {
items.push('<li data-theme="b" data-icon="false" style="height:40px; padding: 7px 0 0 0; font-size: 1.2em"><a href="#displayflat" data-flat="' + row.flatname + '" data-description="' + row.flatdescription + '">' + row.flatdescription + '...' + row.flatname + '</a></li>');
} else {
items.push('<li data-icon="false" style="height:40px; padding: 7px 0 0 0; font-size: 1.2em"><a href="#displayflat" data-flat="' + row.flatname + '" data-description="' + row.flatdescription + '">' + row.flatdescription + '...' + row.flatname + '</a></li>');
}
}
}