views:

23

answers:

1

Ok, here's the situation: I need to display the same record in two different sections. stupid i know, but here's why.

The Report I am building is grouped by one Field, called Day. Each record has date/times, an expected arrival date time, and an expected departure date/time.

so, at this point we have something like this:

Day..............Arrival Time..................Departure Time

18/5.............18/5 9.00am.........19/5 11.00am

The boss only wants to show times that relate to the current day in the arrive/depart coloumns (easy enough with expressions), which ends up like this:

Day..............Arrival Time..................Departure Time

18/5..............9.00am.........................-

the next thing he wants is to display the departing time in the correct day 'group', but as you can imagine as soon as you move to the next row, well you move to the next row of the table.

So the question is: is there anyway to display the same record on multiple coloumns? Have i missed something or have i got an unsolvable problem?

NOTE: this is not the only data in my table either. there is (for example) a name coloumn which also needs to be displayed on both days.

A: 

Cartesian Joins are great for duplicating data...

DECLARE @ArrDep TABLE
(
  Code varchar(1)
)

INSERT INTO @ArrDep (Code) SELECT "A"
INSERT INTO @ArrDep (Code) SELECT "D"

SELECT DateAdd(dd, DateDiff(dd, 0, 
  CASE
    WHEN ad.Code = "A"
    THEN mt.ArrivalTime
    ELSE mt.DepartureTime
  END), 0) as TheDay
  , *
FROM MyTable mt, @ArrDep ad
ORDER BY 1
David B