...iif(orders.fromloc > orders.toloc, locs1.name ) as Startname....Thanks for your great help
>SELECT LEFT(DTOS(date),6) AS CurMonth,; > IIF(FromLoc > ToLoc, FromLoc, ToLoc) AS FromLoc,; > IIF(FromLoc > ToLoc, ToLoc , FromLoc) AS ToLoc,; > COUNT(OrderID) AS Orders, > AVG(Passengers) AS Passengers,; > SUM(Rate) AS Rate; >FROM myTable >WHERE ....; >ORDER BY 1,2,3 >GROUP BY 1,2,3 >>NOT TESTED!
>>select .... locs1.Name as Origin, locs2.Name as Dest .... from orders join locations locs1 on orders.FromLoc=Locations.LocationID ; >>join locations locs2 on orders.ToLoc=Locations.LocationID ..... >>>>
>>>>select left(dtos(date),6) as CurMonth, FromLoc, ToLoc, count(OrderID) as Orders, Avg(Passengers), Sum(Rate) ; >>>>from myTable where .... order by 1,2,3 group by 1,2,3>>>>Works great, but in fact, the problem is i would like to have one row per trip, ie id like to have in the same line if i have FromLoc=x ToLoc=y or FromLoc=y and Toloc=x