SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


"Join" Help


"Join" Help

Author
Message
lijusmail
lijusmail
SSC-Enthusiastic
SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)SSC-Enthusiastic (112 reputation)

Group: General Forum Members
Points: 112 Visits: 193
Hi

Hope that the forum members are doing fine.I would require some help with probably what I feel is "Join". The scenario is as per below

1. Activity table -which has eventid,activityID and statuscode.
2. ActivtyAck table - which has activityid, ackcomments
3. Acitivtyfixed - which has activityid,fixcomments,fixtime
4.Activitycomplete - which has activityid,completecomments,completetime

Once the event is acknowledged it creates an activityid,Each time an event is being fixed it creates activityid, similarly each time an event is being complete it creates an activityid and the comments for each of the fixes and completed are captured in their respective tables.

For eg. Event 102 initially when acknowledged say it creates an activityid 1,when fixing it creates activityid 2 and when completing it creates 3. All the basic information will be held in activity table as shown below

Activity Table
Event ActivityID StatusCode
102 1 D
102 2 F
102 3 F
102 4 C
103 10 D
103 11 C

ActivityAck
ActivityID AckComments AckTime
1 acknowledged 07:30
10 acknowledged 10:02

ActivityFix
ActivityID AckFixComment AckFixTime
2 on site to check 08:45
3 issue with part 09:30

ActivityComplete
ActivityID AckCompleteComment AckCompleteTime
3 issue resolved 10:13
11 changed bulb 12:09

I would like to know whether i could get a report as

EventID,AckFixComment,AckFixtime,AckCompleteComment,AckCompleteTime
102 ,issue with part ,09:30,issue resolved,10:13
103,NULL,NULL,changed bulb,12:09

Any help would be appreciated.

Thanks
Liju
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26153 Visits: 17539
Yes it sounds like you need to join your tables together. What have you tried so far?

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
onlygoodones
onlygoodones
Old Hand
Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)

Group: General Forum Members
Points: 368 Visits: 215
Just a piece of advice: Always its a good practice if you can post the code for creating objects and data. That way, it will be easy for every one as we all do not have to create the objects and the data you are referring to.

Try this:
Select A.eventid, B.ackcomments,C.fixtime,D.completecomments, D.completetime
From Activity A
JOIN ActivtyAck B
ON A.activityID = B.activityID
JOIN Acitivtyfixed C
ON A.activityID= C.activityID
JOIN Activitycomplete D
ON A.activityID= D.activityID
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search