Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GROUPing headache
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01434114
Message ID:
01434133
Views:
51
So simple, so good...Tested, it works great. I can even use
...iif(orders.fromloc > orders.toloc, locs1.name ) as Startname....
Thanks for your great help
Jaime

>O!!!!!!
>I just read your original post much moire carefully.
>How about:
>
>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!
>
>
>
>
>
>>Hey Boris
>>Thanks for the fast answer. In fact, i simplified the query just to ease understanding. I cannot round them, those are id's of locations. In the real select, it looks like
>>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 .....
>>
>>
>>Jaime
>>
>>>>Hi all
>>>>I have data similar to the following:
>>>>OrderID, Date, FromLoc, ToLoc, Passengers, Rate
>>>>I run the following query:
>>>>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
>>>>Any idea how to do this?
>>>>TIA
>>>>Jaime
>>>
>>>If you don't care about FromLoc and ToLoc round them with aggregate function like MAX or MIN.
>>>Be careful though, you may get unexpected results :-)
Why do programs stop working correctly as soon as you leave the Fox?
Previous
Reply
Map
View

Click here to load this message in the networking platform