我用min max 去選兩個時間中最小和最大的。如:
record#: begdate endate
3. 1/1/05. 6/30/06
4. 1/1/07. 12/31/09
我希望的結果是:
1/1/07 - 12/31/09
請問如何實現,而且output是date variable.
非常感謝!
SQL菜鳥請教初級+sql問題(類似上題,有些變動),在線等...
所有跟帖:
• 你的記錄3和4各自代表什麽呀?logic,你為什麽這麽截斷? -veggiedoggie- ♀ (0 bytes) () 11/06/2009 postreply 10:29:50
• 你是否想要MAX BEGDATE和MAX ENDDATE? -:-}---~- ♂ (0 bytes) () 11/06/2009 postreply 10:36:14
• 好象是,嗬嗬,小謀這個IQ題:觀察,然後總結規律。 -veggiedoggie- ♀ (0 bytes) () 11/06/2009 postreply 10:38:24
• 忘了說明一下,3和4中間有間斷,這種情況取most recent時間段。 -小謀- ♀ (0 bytes) () 11/06/2009 postreply 10:47:14
• 回複:忘了說明一下,3和4中間有間斷,這種情況取most recent時間段。 -veggiedoggie- ♀ (27 bytes) () 11/06/2009 postreply 10:53:49
• 好像需要先加一個判斷,再決定用哪個. -小謀- ♀ (0 bytes) () 11/06/2009 postreply 11:01:29
• 你是要找出現最多的最老的日子把?那就複雜多了 -:-}---~- ♂ (31 bytes) () 11/06/2009 postreply 11:09:31
• how to use IF statement in SQL, and compare the current -小謀- ♀ (32 bytes) () 11/06/2009 postreply 11:10:44
• as long as i know, u can't use if in proc sql; -veggiedoggie- ♀ (0 bytes) () 11/06/2009 postreply 11:14:47
• SQL不能比較current and previous record value -:-}---~- ♂ (33 bytes) () 11/06/2009 postreply 11:15:13
• you can use case for if...then...else...if...then...else -:-}---~- ♂ (45 bytes) () 11/06/2009 postreply 11:18:27
• 高人呐,我趕緊做筆記,嗬嗬。 -veggiedoggie- ♀ (104 bytes) () 11/06/2009 postreply 11:27:00
• 說笑了,俺剛古狗來的:) -:-}---~- ♂ (0 bytes) () 11/06/2009 postreply 11:30:56
• too complicated. -小謀- ♀ (0 bytes) () 11/06/2009 postreply 11:34:53
• 沒先謝謝人家? -眼冒金星- ♂ (0 bytes) () 11/06/2009 postreply 11:56:25
• 先謝了 -小謀- ♀ (0 bytes) () 11/06/2009 postreply 12:40:26
• :) -眼冒金星- ♂ (0 bytes) () 11/06/2009 postreply 13:12:54
• 回複:SQL菜鳥請教初級+sql問題(類似上題,有些變動),在線等... -Wonderfullife70- ♀ (51 bytes) () 11/06/2009 postreply 14:19:00
• 回複:SQL菜鳥請教初級+sql問題(類似上題,有些變動),在線等... -nice2u- ♂ (293 bytes) () 11/10/2009 postreply 14:38:35