在SQL中获取记录

时间:2018-05-31 08:16:34

标签: sql sql-server

我有如下查询:

SELECT r.RiderName,
       bm.BranchName,
       oa.AddedOn AS OrderDate,
       ra.CheckIn,
       ra.CheckOut,
       COUNT(om.OrderId) TotalOrder,
       SUM(om.OrderAmount) AS TotalAmount,
       om.OrderId
FROM RiderAttendance ra
INNER JOIN Riders r ON r.RiderId = ra.RiderId
INNER JOIN BranchMaster bm ON bm.BranchId = ra.BranchId
INNER JOIN OrderAssign oa ON oa.RiderId = ra.RiderId
INNER JOIN OrderDetail od ON od.OrderId = oa.OrderId
INNER JOIN OrderMaster om ON od.OrderId = om.OrderId
WHERE od.OrderId != 0
  AND bm.BranchId = 82
  AND oa.AddedOn >= '05/29/2018'
  AND oa.AddedOn <= '05/31/2018'
GROUP BY r.RiderName,
         bm.BranchName,
         oa.AddedOn,
         ra.CheckIn,
         ra.CheckOut,
         om.OrderId

获取image之类的结果。

上面你可以看到sic_name_txt =&#39;公司债券&#39;有两个可能的百分比值,&#39; pgperc1&#39;和&#39; pgperc&#39;,有两个不同的sic_srcid_txt&#39; SARA&#39;和&#39;默认&#39;

我想要与公司债券一起排行&#39; &#39;百分比&#39; &#39; pgperc1&#39;被选中而不是其他

1 个答案:

答案 0 :(得分:0)

将其添加到代码的末尾:

<?= preg_match("/npwp/i", $valueDetail['DTL02CNA'] ) ?  '<label class="label label-success">NPWP Is Exist</label>' : 'Tidak Ada NPWP' ?> <br>