hello!
Problem: I want to select max and min date from the table for every row(GROUPING BY id) then perform date difference operation over it. Afterwards i want to divide that diff with 30 and store in another table. HOW TO DO THAT ?
eX TABLE
Name | Date | ID |
A | 5/3/14 | 1 |
B | 6/4/14 | 2 |
A | 5/4/14 | 1 |
C | 11/8/14 | 3 |
D | 6/7/14 | 4 |
C | 7/7/14 | 3 |
D | 9/9/14 | 4 |
my QUERY
SELECT INSERT INTO <TAB2>
SELECT DATEDIFF/30 AS DIFFFROM
(SELECT MAX(DATE), MIN(DATE) FROM <TAB1>
GROUP BY ID) ;
but its not working pls suggest how to do date