Query SQL to subtract two fields

前端 未结 3 1629
感情败类
感情败类 2020-12-21 21:02

My query is that I have two tables, one called sec_users with the following fields:

pk_user, name, dias_disponibles

And anothe

3条回答
  •  爱一瞬间的悲伤
    2020-12-21 21:11

    The user1 creates another request for 2 days of sick leave, those 2 days of sick leave do not count as requested days. How can I show those two days requested, using the following code:

    SELECT u.pk_user, u.dias_disponibles - sum(s.n_diassolicitados) AS dias_libres 
    FROM   sec_users u
    LEFT JOIN solicitud s 
    on s.fk_empleado = u.pk_user
    GROUP BY u.pk_user
    

提交回复
热议问题