g****n 发帖数: 18 | 3 Hello,
I have a question on using SQL to fill in some missing values in a dataset?
Right now my dataset look like this
ID New_ID Date CV Value
3270001111111 098766 7/31/2007 check 40000
3270001111111 098766 9/30/2007 check 135000
3270001111111 098766 2/28/2008 check 75000
Note there is no date for 8/2007, 10/2007, 11/2007, 12/2007, and 1/2008. I
want to fill in those blanks with the data from previous month, making it
looks like the |
|
B*****g 发帖数: 34098 | 4 ORACLE
WITH
DATA_TABLE AS
(SELECT 3270001111111 ID,'098766' NEWID,TO_DATE('07/31/2007', 'mm/dd/yyyy')
A_DATE,'check' CV,40000 A_VALUE FROM DUAL
UNION ALL
SELECT 3270001111111,'098766',TO_DATE('09/30/2007', 'mm/dd/yyyy'),'check',
135000 FROM DUAL
UNION ALL
SELECT 3270001111111,'098766',TO_DATE('02/28/2008', 'mm/dd/yyyy'),'check',
75000 FROM DUAL
UNION ALL
SELECT 3270001111112,'098757',TO_DATE('10/31/2007', 'mm/dd/yyyy'),'mo' ,
6000 FROM DUAL),
DATE_LIST AS
(SELECT TO_DATE('07/31/2007', 'mm/ |
|