question

sushil721 avatar image
sushil721 asked

combine 2 mysql rows and get one row and mearge some column in mysql..

i have a table `cdr` like below and i want to get the rows which contains `direction='outbound'` and `orig_id` of `inbound` row , and here, `test_id of direction=inbound and direction=outbound are same`..

idcallee_id_numcaller_id_numcaller_id_namedestination_numdirectionorig_idtest_id180011234***890customer8001inbound2f425da869c6d98c2123***7890800180011234567890outboundb7c875a669c6d98c380012234***897customer8001inbound5ea7b70998a9c4214223***7897800180012234567897outbounded35a1e3

98a9c421

580013234***898customer8001inbound5463d51f437dfc6b6323***7898800180013234567898outboundb1af4445437dfc6b

Spectated result like,

idcallee_id_numcaller_id_numcaller_id_namedestination_numdirectionorig_idtest_id2

123***7890

800180011234567890ooutbound2f425da869c6d98c4

223***7897

800180012234567897outbound

5ea7b709

98a9c421

6

323***7898

80018001

3234567898

outbound

5463d51f

437dfc6b

can any one write query for this ? Thanks ..

sql-server-2008sqlmysql
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image KenJ commented ·

what have you tried so far, can you share your query?

also, the sample data is incomprehensible without any spacing or formatting, so it's hard to tell what you are after. If you could either reformat it, or set it up as a create table statement followed by insert statements, that would help tremendously.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.