is my table... 
                  
                  
                  
                  
                  
                  Log {
                  
                  
                  id 
                  
                  
                  user_id 
                  
                  
                  type
                  
                  
                  target_ct
                  
                  
                  target_obj_id 
                  
                  
                  action_ct
                  
                  
                  action_obj_id 
                  
                  
                  workspace_id
                  
                  
                  created_at
                  
                  
                  }
                  
                  
                  i wanna filter out the result based on the window row_number() partition (type, user_id, Minute(created_at)). where row_number <= 6. 
                  
                  
                  
                  
                  
                  i am using recursive query to find all the result for specific action object at nested level. 
                  
                  
                  
                  
                  
                  Query Logic for Log result Filtering for a specific object
                  
                  
                  
                  
                  
                  base query logic 
                  
                  
                        alias row_number() (rn) 
                  
                  
                        filter where workspace_id = <id> and (target_obj_id = <object_id> OR action_obj_id=<object_id>) and rn <=6
                  
                  
                  
                  
                  
                  union all 
                  
                  
                       alias row_number() rn for this query
                  
                  
                       join cte log.target_object_id = cte.action_object_id 
                  
                  
                     where workspace_id=<id> and rn<=6 
                  
                  
                  and last select all from cte.. i am not getting the correct result and missing some records.. for some cases at upper level.. idk why? I'm finding this query correct...  but don't know.... and the same thing happens when i am only filtering without cte using (workspace_id and rn)...
                  
                  
                
 Rahul
                          Singh
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          Rahul
                          Singh
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  can anyone see and analyze pls...
Обсуждают сегодня