Click here to Skip to main content
15,890,512 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Table Grouping Pin
Blue_Boy20-Aug-12 22:15
Blue_Boy20-Aug-12 22:15 
AnswerRe: SQL Table Grouping Pin
i.j.russell20-Aug-12 23:47
i.j.russell20-Aug-12 23:47 
GeneralRe: SQL Table Grouping Pin
milo-xml21-Aug-12 3:03
professionalmilo-xml21-Aug-12 3:03 
GeneralRe: SQL Table Grouping Pin
i.j.russell21-Aug-12 3:53
i.j.russell21-Aug-12 3:53 
GeneralRe: SQL Table Grouping Pin
milo-xml21-Aug-12 4:42
professionalmilo-xml21-Aug-12 4:42 
AnswerRe: SQL Table Grouping Pin
Niladri_Biswas21-Aug-12 22:26
Niladri_Biswas21-Aug-12 22:26 
AnswerRe: SQL Table Grouping Pin
__TR__21-Aug-12 22:28
__TR__21-Aug-12 22:28 
AnswerRe: SQL Table Grouping Pin
milo-xml22-Aug-12 7:54
professionalmilo-xml22-Aug-12 7:54 
Thanks all for your help. Took a little from all the answers. I got the data in the format I want, but not sure it's the most efficient way to do it. First I created a view that had my job data in it(I wasn't sure how to it another way...)
SQL
SELECT dbo.tblFormEvent.PressIndex, dbo.tblFormEvent.JobID, dbo.tblFormEvent.FormID, dbo.tblFormEvent.ShiftID, dbo.tblShift.ClockNumber, MIN(dbo.tblFormEvent.StartEvent) AS StartEvent, MAX(dbo.tblFormEvent.EndEvent) AS EndEvent
FROM dbo.tblFormEvent 
INNER JOIN dbo.tblShift ON dbo.tblFormEvent.PressIndex = dbo.tblShift.PressIndex AND dbo.tblFormEvent.ShiftID = dbo.tblShift.ShiftID
GROUP BY dbo.tblFormEvent.PressIndex, dbo.tblFormEvent.JobID, dbo.tblFormEvent.FormID, dbo.tblFormEvent.ShiftID, dbo.tblShift.ClockNumber

(Forgot I needed the other data from another table as well...)
Then I used that to query the count values from the main table using joins.
SQL
SELECT dbo.View_1.PressIndex, dbo.View_1.JobID, dbo.View_1.FormID, dbo.View_1.ShiftID, dbo.View_1.ClockNumber, dbo.View_1.StartEvent, tblFormEvent_1.StartWaste, tblFormEvent_1.StartGross, dbo.View_1.EndEvent, dbo.tblFormEvent.EndGross, dbo.tblFormEvent.EndWaste
FROM dbo.View_1 LEFT OUTER JOIN dbo.tblFormEvent ON dbo.View_1.PressIndex = dbo.tblFormEvent.PressIndex AND dbo.View_1.JobID = dbo.tblFormEvent.JobID AND dbo.View_1.FormID = dbo.tblFormEvent.FormID AND dbo.View_1.ShiftID = dbo.tblFormEvent.ShiftID AND dbo.View_1.EndEvent = dbo.tblFormEvent.EndEvent LEFT OUTER JOIN dbo.tblFormEvent AS tblFormEvent_1 ON dbo.View_1.StartEvent = tblFormEvent_1.StartEvent AND dbo.View_1.PressIndex = tblFormEvent_1.PressIndex AND dbo.View_1.JobID = tblFormEvent_1.JobID AND dbo.View_1.FormID = tblFormEvent_1.FormID AND dbo.View_1.ShiftID = tblFormEvent_1.ShiftID
ORDER BY dbo.View_1.PressIndex, dbo.View_1.StartEvent


Works, but I have serious doubts about the efficiency. It'll give me something to improve.
AnswerRe: SQL Table Grouping Pin
Michael Potter23-Aug-12 6:16
Michael Potter23-Aug-12 6:16 
Questionssis database reocords to execel sheet Pin
vasu1219-Aug-12 18:56
vasu1219-Aug-12 18:56 
Questionconverting console base application to windows form Pin
shaikh-adil17-Aug-12 7:45
shaikh-adil17-Aug-12 7:45 
AnswerRe: converting console base application to windows form Pin
Eddy Vluggen17-Aug-12 7:57
professionalEddy Vluggen17-Aug-12 7:57 
GeneralMessage Closed Pin
17-Aug-12 8:03
shaikh-adil17-Aug-12 8:03 
GeneralRe: converting console base application to windows form Pin
Paul Conrad17-Aug-12 8:27
professionalPaul Conrad17-Aug-12 8:27 
GeneralMessage Closed Pin
17-Aug-12 8:36
shaikh-adil17-Aug-12 8:36 
GeneralRe: converting console base application to windows form Pin
Paul Conrad17-Aug-12 9:21
professionalPaul Conrad17-Aug-12 9:21 
SuggestionRe: converting console base application to windows form Pin
Eddy Vluggen17-Aug-12 10:17
professionalEddy Vluggen17-Aug-12 10:17 
GeneralMessage Closed Pin
17-Aug-12 19:37
shaikh-adil17-Aug-12 19:37 
GeneralRe: converting console base application to windows form Pin
Eddy Vluggen17-Aug-12 23:02
professionalEddy Vluggen17-Aug-12 23:02 
GeneralMessage Closed Pin
18-Aug-12 5:28
shaikh-adil18-Aug-12 5:28 
GeneralRe: converting console base application to windows form Pin
Eddy Vluggen18-Aug-12 5:53
professionalEddy Vluggen18-Aug-12 5:53 
AnswerRe: converting console base application to windows form Pin
PIEBALDconsult17-Aug-12 9:46
mvePIEBALDconsult17-Aug-12 9:46 
GeneralRe: converting console base application to windows form Pin
Paul Conrad17-Aug-12 11:06
professionalPaul Conrad17-Aug-12 11:06 
AnswerRe: converting console base application to windows form Pin
WebMaster17-Aug-12 12:09
WebMaster17-Aug-12 12:09 
QuestionData Source Not Found on Windows using MyODBC (MySQL) connector Pin
QuickBooksDev17-Aug-12 7:13
QuickBooksDev17-Aug-12 7:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.