Digitalcandy
IS-IT--Management
MS SQL 2000
I have two tables, dbo.TravelerLot and dbo.Process. Process has a "many to one" relationship with TravelerLot.
dbo.TravelerLot INNER JOIN
dbo.Process ON dbo.TravelerLot.CurrentProcID = dbo.Process.ProcessID
I am trying to make a view that has grouping. I'm having a little trouble with the code to make the grouping the way I want.
Without grouping I have something like so;
dbo.TravelerLot.LotID dbo.TravelerLot.TravLotID dbo.Process.ProcNum
1 100 5
1 101 10
1 102 3
1 103 30
2 220 500
2 210 23
2 240 400
3 45 100
3 46 90
With the propper grouping I'd like my view to look like the example below based on the data example above, (data is returned based on the lowest ProcNum);
dbo.TravelerLot.LotID dbo.TravelerLot.TravLotID dbo.Process.ProcNum
1 102 3
2 210 23
3 46 90
I need the grouping to happen based on TravelerLot.LotID, however, I also need TravelerLot.TravLotID to be visible but it needs to return the the TravLotID that has the lowest Process.ProcNum value.
Can one of you experts make this happen? I don't know much about SQL programming but this would really help for report writing.
TIA.
I have two tables, dbo.TravelerLot and dbo.Process. Process has a "many to one" relationship with TravelerLot.
dbo.TravelerLot INNER JOIN
dbo.Process ON dbo.TravelerLot.CurrentProcID = dbo.Process.ProcessID
I am trying to make a view that has grouping. I'm having a little trouble with the code to make the grouping the way I want.
Without grouping I have something like so;
dbo.TravelerLot.LotID dbo.TravelerLot.TravLotID dbo.Process.ProcNum
1 100 5
1 101 10
1 102 3
1 103 30
2 220 500
2 210 23
2 240 400
3 45 100
3 46 90
With the propper grouping I'd like my view to look like the example below based on the data example above, (data is returned based on the lowest ProcNum);
dbo.TravelerLot.LotID dbo.TravelerLot.TravLotID dbo.Process.ProcNum
1 102 3
2 210 23
3 46 90
I need the grouping to happen based on TravelerLot.LotID, however, I also need TravelerLot.TravLotID to be visible but it needs to return the the TravLotID that has the lowest Process.ProcNum value.
Can one of you experts make this happen? I don't know much about SQL programming but this would really help for report writing.
TIA.