作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
CREATE DEFINER=`root`@`localhost` PROCEDURE `My_PRO`(in employeId int)
BEGIN
declare allocatedvalue1 int default 0;
declare allocatedvalue2 int default 0;
declare appliedvalue1 int default 0;
declare appliedvalue2 int default 0;
set allocatedvalue1=(
SELECT sum(day) FROM Parabola.leave_allocated where employee_id=741 and
leave_type_id=42 and year='2016') ;
set appliedvalue1=(
select IFNULL(FORMAT(sum(hours/8),1),0)from leave_applied where
employee_id=741 and leave_type_id in(42) and status in (1,2,5)and
(start_date>='2016-01-01'
and end_date<='2016-12-31' ));
set allocatedvalue2=(
select sum(day) from compensatory_leave where
employee_id=741 and status in(2,3));
set appliedvalue2=(
select sum(day) from compensatory_leave where
employee_id=741);
END
这是我的程序,我想像这样显示值
**label applied**
FirstLeave allocatedvalue1/appliedvalue1
SecondLeave allocatedvalue2/ appliedvalue2
请建议我如何编写内部程序,以便我可以获得像给定结构一样的值我能够在所有分配的值 1、应用值 1 中获得值……但我无法选择值以便获得所需的值。
最佳答案
看看这个:
select 'FirstLeave' as FirstLeave,allocatedvalue1/appliedvalue1 as fvalue1
union all
select 'SecondLeave' as SecondLeave, allocatedvalue2/ appliedvalue2 as fvalue2
关于mysql - 如何在mySql中选择值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39585979/
我是一名优秀的程序员,十分优秀!