TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhishek Jaiswal
95
19.8k
9.6m
SQL query
Aug 28 2014 8:59 AM
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
Reply
Answers (
5
)
How to get distinct values in 2 columns in SQL server table
SQL server ERROR