+static void ipair_gettrades(int si, int di) {
+ char *stmt= masprintf
+ ("SELECT\n"
+ " sell.price src_price,\n"
+ " sum(sell.qty) src_qty,\n"
+ " buy.price dst_price,\n"
+ " sum(buy.qty) dst_qty,\n"
+ " commods.commodid commodid,\n"
+ " commods.unitmass unitmass,\n"
+ " commods.unitvolume unitvolume\n"
+ " FROM commods\n"
+ " JOIN sell ON commods.commodid = sell.commodid\n"
+ " JOIN buy ON commods.commodid = buy.commodid\n"
+ " WHERE buy.price > sell.price\n"
+ " AND sell.islandid=%d\n"
+ " AND buy.islandid=%d\n"
+ " GROUP BY commods.commodid, sell.price, buy.price\n",
+ si, di);
+
+ printf("SQL\n[\n%s\n]\n", stmt);
+
+ free(stmt);
+}
+