Consulting

Results 1 to 2 of 2

Thread: distinct rows based on combination of columns

  1. #1

    distinct rows based on combination of columns

    Hi,
    I have the table for train journey col 1 - From destinationn col 2 - To Destination col C distance
    now i want to write a query to ge the unique journeys that are available?

    for example there will be rows for
    From - London To Paris
    From Paris To London,

    basically both are same trip, so wanted to get just one in my result?
    how do i write a query to get this

    Regards
    Arvind

  2. #2
    Aravimdan_3. The distinct only works when the 2 columns are unique. Distinct is made to avoid duplicate, but in order to work all the selected combined columns must be unique. Therefore London to Paris is unique within its own row, and Paris to London is unique with its own row. GPS systems uses kinda the same system but in order to work you must specify the From Location to Destination Location. If the trips a round trip you have then to invert the locations in order to work, cuz your first trip might be shorter then your returning trip and your returning trip might take you to different roads.

    your locations are stored in one table only?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •