Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

sum between two values

$
0
0

Experts,

How to get sum between these two values ?

SELECT

      [Soldtopt],

	  [tradingname],
	  [DlvDate],
	  SUM(try_cast(Netvalue as float)) as Netvalue,
	 count(distinct SDDoc)   as Salesdoc ,
	 count(distinct case when  Netvalue = '0' then 1 else null end) as ZeroValue ,

	 sum (count(distinct SDDoc)) , (count(distinct case when  Netvalue = '0' then 1 else null end)) As result

  FROM [FOC].[dbo].[foc]


	GROUP by Soldtopt,tradingname,DlvDate  ORDER BY  count (distinct SDDoc) DESC;

is this correct to way to bring the sum(

sum (count(distinct SDDoc)) , (count(distinct case when  Netvalue = '0' then 1 else null end)) As result)

? or i am getting error "

Msg 130, Level 15, State 1, Line 13
Cannot perform an aggregate function on an expression containing an aggregate or a subquery."


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>