需要help/guide for sql select查询,我有2个表股和stock_history,股票将有股票 和更新股票表之前的初始值,stock_history会从股票表中插入1st,我的情况是需要根据选择日期获取库存状态, 这是为了跟踪未平仓的库存余额和平仓库存余额,只需要从表库 中获取特定时间戳的数据,库存平衡很容易,但是关键部分是什么时候获取开放股票余额的数据,需要跟踪特定时间戳的状态,这只能通过引用历史表来完成,所以我需要sql需要从股票和stock_history中选择数据sql查询select语句
status table
id desc
-- ----
01 consignment
02 customer
03 bank
04 safekeep
05 exit
stock
-----
ref_no serial_no status timeStamp
1 001 04 2012-03-01 09:03:00
stock_history
-------------
ref_no serial_no status timeStamp
1 001 01 2012-03-01 09:00:00
1 001 03 2012-03-01 09:01:00
1 001 02 2012-03-01 09:02:00
so, when choose for date
01/03/12 time 9:01 = 1 001 03 2012-03-01 09:01:00
01/03/12 time 9:01 = 1 001 03 2012-03-01 09:01:00
请帮助,在此先感谢
'ALL'只允许重复。由于在这种模式下它们是不可能的,所以它在这里不会做任何不同的事情,而不是我的答案离开它。 – 2012-03-19 08:43:28
@BenLee:“*它没有做任何不同的事*” - 除了更快;) – 2012-03-19 08:50:01
touche。但难道你不能把它作为我的答案的评论而不是新的答案吗?我想更新我的答案,以提高效率。 – 2012-03-19 08:52:11