马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
先看看sql 语句: select * from ( select CompanyID, Max(NewsDate) as LastestNewsDate from news group by CompanyID )c LEFT JOIN ( select SecurityID, Max(PriceDate) as LastestPriceDate from stock_data group by SecurityID )b ON b.SecurityID = c.CompanyID ========================================================= 现象如下:执行的结果中LastestPriceDate 总是和LastestNewsDate完全一样(当然实际table中的数据不一样),感觉就像是copy的。感觉极其想不通,跟踪了一下query plan(DBArtisan 8.1),结果: QUERY PLAN FOR STATEMENT 1 (at line 1).
STEP 1 The type of query is SELECT (into Worktable1). GROUP BY Evaluate Grouped MAXIMUM AGGREGATE.
FROM TABLE news Nested iteration. Table Scan. Forward scan. Positioning at start of table. Using I/O Size 8 Kbytes for data pages. With LRU Buffer Replacement Strategy for data pages. TO TABLE Worktable1.
STEP 2 The type of query is SELECT.
FROM TABLE Worktable1. Nested iteration. Table Scan. Forward scan. Positioning at start of table. Using I/O Size 8 Kbytes for data pages. With MRU Buffer Replacement Strategy for data pages.
FROM TABLE Worktable1. Nested iteration. Using Clustered Index. Forward scan. Positioning by key. Using I/O Size 8 Kbytes for data pages. With MRU Buffer Replacement Strategy for data pages. 感觉 select SecurityID, Max(PriceDate) as LastestPriceDate from stock_data group by SecurityID中的聚合函数根本就没有执行。 请高手指教,[em03] |