|
|
@@ -230,20 +230,17 @@ func (r *TjmdTodayAccountMargin) calc() {
|
|
|
|
|
|
func (r *TjmdTodayAccountMargin) buildSql() string {
|
|
|
var sqlId utils.SQLVal = `
|
|
|
-select *
|
|
|
- from (select t.accountid,
|
|
|
- t.goodsid,
|
|
|
- t.infocontent,
|
|
|
- t.marketid,
|
|
|
- row_number() over(partition by t.goodsid, t.marketid order by t.accountid desc) cnt
|
|
|
- from today_accountmargin t) a
|
|
|
- where a.cnt = 1
|
|
|
+select t.accountid, t.goodsid, t.infocontent, t.createdate, t.marketid
|
|
|
+ from today_accountmargin t
|
|
|
+ where 1 = 1
|
|
|
`
|
|
|
if r.ACCOUNTID > 0 {
|
|
|
- sqlId.JoinFormat(" and a.ACCOUNTID in(0, %v)", r.ACCOUNTID)
|
|
|
+ sqlId.JoinFormat(" and t.ACCOUNTID in(0, %v)", r.ACCOUNTID)
|
|
|
}
|
|
|
- sqlId.AndEx("a.GOODSID", r.GOODSID, r.GOODSID > 0)
|
|
|
- sqlId.AndEx("a.MARKETID", r.MARKETID, r.MARKETID > 0)
|
|
|
+ sqlId.AndEx("t.GOODSID", r.GOODSID, r.GOODSID > 0)
|
|
|
+ sqlId.AndEx("t.MARKETID", r.MARKETID, r.MARKETID > 0)
|
|
|
+ sqlId.Join(" order by t.accountid desc")
|
|
|
+ sqlId.Page(1, 1) // 只取一条
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|