Does it matter which is 1 ? Rows have no order, strictly speaking.
Is it always 2 for 1?
You can achieve this in any shell, awk, perl, C, C++, JAVA or SQL:
select
Account_id,
"Trip_Org1="
|| a.Trip_Org
|| ",Trip_Org2="
|| b.Trip_Org
AS Trip_Org,
"Trip_Dest1="
|| a.Trip_Dest
|| ",Trip_Dest2="
|| b.Trip_Dest
AS Trip_Dest,
"City1="
|| a.City
|| ",City2="
|| b.City
AS City,
"Hotel_Nm1="
|| a.Hotel_Nm
|| ",Hotel_Nm2="
|| b.Hotel_Nm
AS Hotel_Nm
from
input a
join input b
using Account_id
where
a.Trip_Org < b.Trip_Org
order by 1
If e.g. the key value in col 1 will change, pls make up your own solution checking for col 1, print out values so far, delete the Out array and start over...
You can do something similar in bash with indexed arrays for the input, saved header, and output, if in a subshell you add '|' to the front of $IFS (If the word is double-quoted, ${name
[*]} expands to a single word with the value of each array member separated by the first character of the IFS special variable), read -a, etc. that will accomodate any nnumber and name columns and rows dynamically (assuming they are sorted on the key column). The usual challenges on starting and ending the loop do not go away. That is why they invented SQL, text ODBC and JDBC, Excel, etc.