Microsoft
Software
Hardware
Network
Question : T-SQL help table join
I have two tables:
T1.WORK_ID T1.COMPANY_NAME T1.work_LOCATION
1 TEST_COMPANY1 TEST_COMPANY1_LOC1
2 TEST_COMPANY1 TEST_COMPANY1_LOC2
3 TEST_COMPANY1 TEST_COMPANY1_LOC3
4 TEST_COMPANY2 TEST_COMPANY2_LOC1
5 TEST_COMPANY2 TEST_COMPANY2_LOC2
6 TEST_COMPANY2 TEST_COMPANY2_LOC3
T2.WORK_ID T2.start_date_time T2.end_date_time
1 2010-01-02 8:00 2010-01-02 11:00
2 2010-01-03 8:00 2010-01-03 10:00
3 2010-01-05 8:00 2010-01-05 11:30
4 2010-02-10 8:00 2010-02-10 09:30
5 2010-02-12 8:00 2010-02-12 12:00
6 2010-02-15 8:00 2010-02-15 10:30
The result I am looking for is:
COMPANY_NAME START_DATE_TIME END_DATE_TIME
TEST_COMPANY1 2010-01-02 8:00 2010-01-05 11:30
TEST_COMPANY2 2010-02-10 8:00 2010-02-15 10:30
note:
DISTINCT BY T1.COMPANY_NAME, EARLY_START_DATE_TIME, LAST_END_DATE_TIME
The T1 and T2 match by work_id
Thank you,
Answer : T-SQL help table join
SELECT T1.COMPANY_NAME, MIN(T2.start_date_time) AS START_DATE_TIME, MAX(T2.end_date_time) AS END_DATE_TIME
FROM T1 INNER JOIN
T2 ON T1.WORK_ID = T2.WORK_ID
GROUP BY T1.COMPANY_NAME
Random Solutions
How do I convert string to char?
Standard server 2008 to SBS premium 2008
oracle forms record group question
Access user control function from master page
Am I elegible for a free upgrade to Outlook 2010 with this?
SCCM Software Report By Major Revision
How to change properties.settings after deployment of windows application
Sign In Request from Outlook for calendars.office.microsoft
.com
IE is blocking my download of Adobe Flash, I'm getting install error.
How do I resolve this error "javax.xml.ws.WebServiceEx
ception .... Place the resource correctly in the classpath.?