通过在 mysql 中运行良好但在 BIRT 中运行良好来排序?

Order by working well in mysql but not in BIRT?

我有这个问题

select item.No_, item.Description,
group_concat(date_format(item_ledger_entry.Posting_Date,"%m/%d/%Y") separator '\n') AS Grouped_Date
from pbsdev3.item, pbsdev3.item_ledger_entry
where item.No_ = item_ledger_entry.Item_No_
group by No_
order by Posting_Date;

而mysqldb中的结果是这样的,是正确的

01/09/2009
01/09/2009
01/10/2009

但是当我在我的 BIRT 报告设计器中执行此操作时,它的顺序不再相同,它看起来像:

01/10/2009
01/09/2009
01/09/2009

我希望它降序排列。 我试过 order by Posting_Date descasc 但 birt 的结果是一样的。

为什么会这样?我错过了什么吗?

你期待什么?您没有指定顺序,因此顺序是任意的。两次运行之间可能会有所不同;它可能因数据库而异。

这很容易修复:

select i.No_, i.Description,
       group_concat(date_format(ile.Posting_Date, '%m/%d/%Y') order by ile.Posting_date separator '\n' ) AS Grouped_Date
from pbsdev3.item i join
     pbsdev3.item_ledger_entry ile
     on i.No_ = ile.Item_No_
group by i.No_
order by ile.Posting_Date;

order by 指定值的顺序。这应该 return 在两个系统上得到相同的结果。