jeudi 30 juin 2016

Why is the same SQL sometimes report errors, some time it runs fine?

This is the SQL statement:

select 
    ua.*, uuu.user_name 
from
    (select 
         ud.dev_id, 
         (select uud.user_id as user_id 
          from user_device uud 
          where ud.dev_id = uud.dev_id and assigned = 1) user_id,
         (select count(1) 
          from user_device du 
          where du.dev_id = ud.dev_id) user_number, 
         de.license
     from 
         user_device ud 
     inner join 
         device de on ud.dev_id = de.dev_id 
     where ud.user_id = 'XXXXXX') ua 
left join 
    user_info uuu on uuu.user_id = ua.user_id 

Execute the same SQL, it sometimes reports this error, but sometimes it runs just fine.

The error :

error

and this is what I want (with another user_id yesterday)

enter image description here

Aucun commentaire:

Enregistrer un commentaire