我很难创建一个 Oracle 查询来报告某些日子(一系列月份中每个月的第一天)的订单历史状态。我搜了又搜,没有人问类似的问题。这似乎是一个直截了当的问题,所以希望有人能提供帮助!这是我的例子:
订单表:
ORDER_NUMBER STATUS DATE
50001000 Created 01-15-2010
50001000 Released 02-20-2010
50001000 Completed 02-25-2010
50001000 Closed 03-10-2010
50001035 Created 01-20-2010
50001035 Released 01-25-2010
50001035 Completed 04-05-2010
50001035 Closed 05-30-2010
所以我需要的输出是每个月初每个订单的状态。像这样的东西:
DATE ORDER_NUMBER STATUS
12-01-2009
01-01-2010
02-01-2010 50001000 Created
02-01-2010 50001035 Released
03-01-2010 50001000 Completed
03-01-2010 50001035 Released
04-01-2010 50001000 Closed
04-01-2010 50001035 Released
05-01-2010 50001000 Closed
05-01-2010 50001035 Completed
06-01-2010 50001000 Closed
06-01-2010 50001035 Closed
07-01-2010 50001000 Closed
07-01-2010 50001035 Closed
..etc
是否有一些本机关键字可以在没有大量连接和子查询的情况下完成这项工作?
谢谢,
加勒特