如何根据不同条件在mysql中对列进行分组

时间:2019-05-19 11:44:27

标签: mysql sql database

我有一张桌子,上面有员工要提取的预付款详情。所以有两种类型,贷方和借方,贷方是当我们向员工预支薪金时,借方是当我们从员工的工资中扣除金额时。 所以我只需要一个查询,就可以看到每位员工的预付款和预付款。

我尝试做concat和group concat,但是无法获取我需要的查询。

SELECT *
FROM themefoods.advance_transaction;

select sum(amount) as amountTaken, employee_id, type_of_advance 
from advance_transaction
group by employee_id, type_of_advance;

预期输出是带有列的表 ID; amount_taken; advance_pending; employee_id

附加示例表。

Table view of the advance table

1 个答案:

答案 0 :(得分:0)

您似乎正在寻找条件汇总:

 for(var i=0;(i)<points.length;i++){
    var pts = points[i];
    var top = new THREE.Vector3(pts.x , pts.y , 50 );
    var bottom = new THREE.Vector3( pts.x , pts.y , -50 );

   //start raycaster

   var raycaster = new THREE.Raycaster();
   raycaster.set( top, bottom );

   // calculate objects intersecting the picking ray
   var intersects = rayCaster.intersectObjects(scene.getObjectByName('MyObj_s').children, false);

if (intersects.length > 0){
    console.log(intersects[0].point);
 }