SELECT DISTINCT 
conversationId, startTime, endTime, ownerJid, ownerResource, withJid, withResource, subject, thread, 
participantid, jid, nick, 
messageId, time, direction, type, subject, body 
FROM archiveConversations 
INNER JOIN archiveParticipants ON archiveConversations.conversationId = archiveParticipants.conversationId 
INNER JOIN archiveMessages ON archiveParticipants.conversationId = archiveMessages.conversationId ; 

CONVERSATIONID STARTTIME     ENDTIME       OWNERJID              OWNERRESOURCE WITHJID               WITHRESOURCE SUBJECT THREAD PARTICIPANTID JID                   NICK   MESSAGEID TIME          DIRECTION TYPE SUBJECT BODY                       
-------------- ------------- ------------- --------------------- ------------- --------------------- ------------ ------- ------ ------------- --------------------- ------ --------- ------------- --------- ---- ------- -------------------------- 
1              1313598616375 1313598733462 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  8xTCGT 1             andy@derek.gltd.local [null] 1         1313598616375 from      chat [null]  wotcha                     
1              1313598616375 1313598733462 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  8xTCGT 1             andy@derek.gltd.local [null] 3         1313598696092 from      chat [null]  wotcha you                 
1              1313598616375 1313598733462 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  8xTCGT 1             andy@derek.gltd.local [null] 5         1313598733462 from      chat [null]  wotcha you again           
1              1313598616375 1313598733462 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  8xTCGT 2             leon@derek.gltd.local [null] 1         1313598616375 from      chat [null]  wotcha                     
1              1313598616375 1313598733462 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  8xTCGT 2             leon@derek.gltd.local [null] 3         1313598696092 from      chat [null]  wotcha you                 
1              1313598616375 1313598733462 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  8xTCGT 2             leon@derek.gltd.local [null] 5         1313598733462 from      chat [null]  wotcha you again           
2              1313598649280 1313598735837 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  8xTCGT 3             leon@derek.gltd.local [null] 2         1313598649280 to        chat [null]  wotcha                     
2              1313598649280 1313598735837 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  8xTCGT 3             leon@derek.gltd.local [null] 4         1313598698104 to        chat [null]  wotcha you                 
2              1313598649280 1313598735837 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  8xTCGT 3             leon@derek.gltd.local [null] 6         1313598735837 to        chat [null]  wotcha you again           
2              1313598649280 1313598735837 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  8xTCGT 4             andy@derek.gltd.local [null] 2         1313598649280 to        chat [null]  wotcha                     
2              1313598649280 1313598735837 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  8xTCGT 4             andy@derek.gltd.local [null] 4         1313598698104 to        chat [null]  wotcha you                 
2              1313598649280 1313598735837 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  8xTCGT 4             andy@derek.gltd.local [null] 6         1313598735837 to        chat [null]  wotcha you again           
3              1313599020301 1313599020301 leon@derek.gltd.local [null]        andy@derek.gltd.local Spark 2.6.3  [null]  Q5t6nB 5             leon@derek.gltd.local [null] 7         1313599020301 from      chat [null]  hola again                 
3              1313599020301 1313599020301 leon@derek.gltd.local [null]        andy@derek.gltd.local Spark 2.6.3  [null]  Q5t6nB 6             andy@derek.gltd.local [null] 7         1313599020301 from      chat [null]  hola again                 
4              1313599026395 1313599026395 andy@derek.gltd.local Spark 2.6.3   leon@derek.gltd.local [null]       [null]  Q5t6nB 7             andy@derek.gltd.local [null] 8         1313599026395 to        chat [null]  hola again                 
4              1313599026395 1313599026395 andy@derek.gltd.local Spark 2.6.3   leon@derek.gltd.local [null]       [null]  Q5t6nB 8             leon@derek.gltd.local [null] 8         1313599026395 to        chat [null]  hola again                 
5              1313599041768 1313599041768 andy@derek.gltd.local Spark 2.6.3   leon@derek.gltd.local Spark 2.6.3  [null]  mRG93E 9             andy@derek.gltd.local [null] 9         1313599041768 from      chat [null]  yep?                       
5              1313599041768 1313599041768 andy@derek.gltd.local Spark 2.6.3   leon@derek.gltd.local Spark 2.6.3  [null]  mRG93E 10            leon@derek.gltd.local [null] 9         1313599041768 from      chat [null]  yep?                       
6              1313599046418 1313599046418 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local Spark 2.6.3  [null]  mRG93E 11            leon@derek.gltd.local [null] 10        1313599046418 to        chat [null]  yep?                       
6              1313599046418 1313599046418 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local Spark 2.6.3  [null]  mRG93E 12            andy@derek.gltd.local [null] 10        1313599046418 to        chat [null]  yep?                       
7              1313663357850 1313663357850 leon@derek.gltd.local [null]        andy@derek.gltd.local Spark 2.6.3  [null]  59Mzsw 13            leon@derek.gltd.local [null] 11        1313663357850 from      chat [null]  yo                         
7              1313663357850 1313663357850 leon@derek.gltd.local [null]        andy@derek.gltd.local Spark 2.6.3  [null]  59Mzsw 14            andy@derek.gltd.local [null] 11        1313663357850 from      chat [null]  yo                         
8              1313663366326 1313663366326 andy@derek.gltd.local Spark 2.6.3   leon@derek.gltd.local [null]       [null]  59Mzsw 15            andy@derek.gltd.local [null] 12        1313663366326 to        chat [null]  yo                         
8              1313663366326 1313663366326 andy@derek.gltd.local Spark 2.6.3   leon@derek.gltd.local [null]       [null]  59Mzsw 16            leon@derek.gltd.local [null] 12        1313663366326 to        chat [null]  yo                         
9              1315925172612 1315925208656 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  64Kx9e 17            andy@derek.gltd.local [null] 13        1315925172612 from      chat [null]  hi andy                    
9              1315925172612 1315925208656 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  64Kx9e 17            andy@derek.gltd.local [null] 17        1315925195800 from      chat [null]  how you been andy?         
9              1315925172612 1315925208656 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  64Kx9e 17            andy@derek.gltd.local [null] 23        1315925208656 from      chat [null]  alright, andy, I'll see ya 
9              1315925172612 1315925208656 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  64Kx9e 18            leon@derek.gltd.local [null] 13        1315925172612 from      chat [null]  hi andy                    
9              1315925172612 1315925208656 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  64Kx9e 18            leon@derek.gltd.local [null] 17        1315925195800 from      chat [null]  how you been andy?         
9              1315925172612 1315925208656 andy@derek.gltd.local [null]        leon@derek.gltd.local Spark 2.6.3  [null]  64Kx9e 18            leon@derek.gltd.local [null] 23        1315925208656 from      chat [null]  alright, andy, I'll see ya 
10             1315925172676 1315925208659 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  64Kx9e 19            leon@derek.gltd.local [null] 14        1315925172676 to        chat [null]  hi andy                    
10             1315925172676 1315925208659 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  64Kx9e 19            leon@derek.gltd.local [null] 18        1315925195803 to        chat [null]  how you been andy?         
10             1315925172676 1315925208659 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  64Kx9e 19            leon@derek.gltd.local [null] 24        1315925208659 to        chat [null]  alright, andy, I'll see ya 
10             1315925172676 1315925208659 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  64Kx9e 20            andy@derek.gltd.local [null] 14        1315925172676 to        chat [null]  hi andy                    
10             1315925172676 1315925208659 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  64Kx9e 20            andy@derek.gltd.local [null] 18        1315925195803 to        chat [null]  how you been andy?         
10             1315925172676 1315925208659 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local [null]       [null]  64Kx9e 20            andy@derek.gltd.local [null] 24        1315925208659 to        chat [null]  alright, andy, I'll see ya 
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 21            leon@derek.gltd.local [null] 15        1315925188145 from      chat [null]  hi leon                    
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 21            leon@derek.gltd.local [null] 19        1315925198905 from      chat [null]  good leon                  
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 21            leon@derek.gltd.local [null] 21        1315925202457 from      chat [null]  i gotta head off mate      
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 21            leon@derek.gltd.local [null] 25        1315925212225 from      chat [null]  bye leon                   
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 22            andy@derek.gltd.local [null] 15        1315925188145 from      chat [null]  hi leon                    
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 22            andy@derek.gltd.local [null] 19        1315925198905 from      chat [null]  good leon                  
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 22            andy@derek.gltd.local [null] 21        1315925202457 from      chat [null]  i gotta head off mate      
11             1315925188145 1315925212225 leon@derek.gltd.local Spark 2.6.3   andy@derek.gltd.local spark        [null]  1F6bqD 22            andy@derek.gltd.local [null] 25        1315925212225 from      chat [null]  bye leon                   
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 23            andy@derek.gltd.local [null] 16        1315925188151 to        chat [null]  hi leon                    
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 23            andy@derek.gltd.local [null] 20        1315925198907 to        chat [null]  good leon                  
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 23            andy@derek.gltd.local [null] 22        1315925202459 to        chat [null]  i gotta head off mate      
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 23            andy@derek.gltd.local [null] 26        1315925212227 to        chat [null]  bye leon                   
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 24            leon@derek.gltd.local [null] 16        1315925188151 to        chat [null]  hi leon                    
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 24            leon@derek.gltd.local [null] 20        1315925198907 to        chat [null]  good leon                  
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 24            leon@derek.gltd.local [null] 22        1315925202459 to        chat [null]  i gotta head off mate      
12             1315925188151 1315925212227 andy@derek.gltd.local spark         leon@derek.gltd.local Spark 2.6.3  [null]  1F6bqD 24            leon@derek.gltd.local [null] 26        1315925212227 to        chat [null]  bye leon                   
