共获得两个不同的列

时间:2015-07-21 13:01:25

标签: sql

我需要生成两个不同列的总和。

我的查询看起来像这样

SELECT 0 AS OTHER_AMT, ABS([MISC AMT]*100) AS MISC_AMT FROM ESCHEATMENT_FINAL WHERE [TRAN DT] < '6/30/2012' AND [MISC AMT]<>0

UNION ALL

SELECT ABS([DEP AMT]*100+[INT AMT]*100) AS OTHER_AMT, 0 AS MISC_AMT FROM [CCC_Escheatment].[dbo].[ESCHEATMENT_FINAL] WHERE [TRAN DT] < '6/30/2014' AND [DEP AMT]<>0

我需要MISC_AMT和OTHER_AMT的合计总金额。我该怎么做呢

1 个答案:

答案 0 :(得分:2)

public static function replaceSlug($name, $value)
{
   $fullUrl = self :: getFullUrl();
   $queryString = parseUrl($fullUrl, PHP_URL_QUERY);   

   $slugs = array();
   parse_str($queryString, $slugs);

   foreach ($slugs as &$slug) {
      if ($slug == $name) {
         if ($value == null) {
            unset($slug);
         } else {
            $slug = $value;
         }
      }
   }

   return ''; // what to return?
}