This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

help is SQL query to SUM 2 Colum's

Hi

i have created sql query to sum 2 colums but its not showing any data

SELECT
NodesCustomProperties.ATM + NodesCustomProperties.BRANCH_TYPE AS [Total Branches]
,NodesCustomProperties.City

FROM dbo.NodesCustomProperties


WHERE NodesCustomProperties.ATM_Branches = 'ATM Branches'
AND NodesCustomProperties.BRANCH_TYPE = 'NON-ATM'

what result i want 

Total ATM Branches Total Non-ATM Branches Total Branches City
10 11 21 Karachi
31 41 72 Lahore
Parents
  • I dont know if I understood you correctly but you can try something like that

    select 
    	isnull(t1.[Total ATM Branches],0), 
    	isnull(t2.[Total Non-ATM Branches],0), 
    	isnull(t1.[Total ATM Branches],0) + isnull(t2.[Total Non-ATM Branches],0) as [Total], 
    	t2.City from 
    	(select 
    		count(nodeid) as [Total ATM Branches], 
    		City 
    	from [dbo].[NodesCustomProperties]
    	where NodesCustomProperties.ATM_Branches = 'ATM Branches'
    	group by NodesCustomProperties.City) as t1 
    full join
    	(select 
    		count(nodeid) as [Total Non-ATM Branches], 
    		city 
    	from [dbo].[NodesCustomProperties]
    	where NodesCustomProperties.BRANCH_TYPE = 'NON-ATM'
    	group by NodesCustomProperties.City) as  t2 
    on t1.city = t2.city

  • many thanks , urs provided quey works for me 

Reply Children
No Data