开发者

Total a Value and Return Value in Same Column

开发者 https://www.devze.com 2023-02-16 18:42 出处:网络
In my SQL i have a column like this SUM(ISNULL(CAST(A.ODEN开发者_运维百科EN_ANAPARA AS FLOAT),0)+ISNULL(CAST(A.FAIZ AS FLOAT),0)+

In my SQL i have a column like this

SUM(ISNULL(CAST(A.ODEN开发者_运维百科EN_ANAPARA AS FLOAT),0)+ISNULL(CAST(A.FAIZ AS FLOAT),0)+
      ISNULL(CAST(A.BSMV AS FLOAT),0)+ISNULL(CAST(A.GECIKME_FAIZ AS FLOAT),0)+
      ISNULL(CAST(A.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN'

and i have a function getting another value like that;

USE [Example]
GO
/****** Object:  UserDefinedFunction [dbo].[fngcodeme]    Script Date: 03/15/2011 11:52:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER FUNCTION [dbo].[fngcodeme]
(
    @HESAP INT,@BAS DATE, @BIT DATE,@DOV INT
)
RETURNS FLOAT

AS
BEGIN

RETURN( 
    SELECT SUM(TUTAR)
    FROM YAZ..MARDATA.M_GHAREKET
    WHERE TEMEL_HESAP = @HESAP
    AND DOVIZ_KOD = @DOV
    AND REF_KOD = 'GC'
    AND BACAK_GRUP = 'PERT'
    AND ISL_KOD = 1
    AND ISL_TAR >= @BAS 
    AND ISL_TAR <= @BIT
)
END

What i want is total of first SQL and function on same column.

(Example: "Yatan" is A, Function return value is B, I want one colum A + B)

Best Regards, Soner


select
   SUM(ISNULL(CAST(A.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(A.FAIZ AS FLOAT),0)+
      ISNULL(CAST(A.BSMV AS FLOAT),0)+ISNULL(CAST(A.GECIKME_FAIZ AS FLOAT),0)+
      ISNULL(CAST(A.GECIKME_BSMV AS FLOAT),0)) 
   + dbo.fngcodeme(@HESAP,@BAS,@BIT,@DOV)
from ...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号