<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: SQL Puzzle: SQL Advance Query &#8211; Find the average shared salary by each department	</title>
	<atom:link href="https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-the-average-shared-salary-by-each-department/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-the-average-shared-salary-by-each-department/</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 01 Aug 2019 10:56:16 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.5</generator>
	<item>
		<title>
		By: ANIL		</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-the-average-shared-salary-by-each-department/#comment-7603</link>

		<dc:creator><![CDATA[ANIL]]></dc:creator>
		<pubDate>Thu, 01 Aug 2019 10:56:16 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6597#comment-7603</guid>

					<description><![CDATA[SELECT DEPTID,DEPTSAL,TOTSAL,(DEPTSAL*100/TOTSAL)AS PER
FROM

(SELECT DEPTID,SUM(SALARY)AS DEPTSAL,
(SELECT SUM(A.SALARY) AS TOTSAL FROM TBL_EMP A WHERE A.DEPTID=DEPTID) AS TOTSAL

FROM TBL_EMP GROUP BY DEPTID ORDER BY DEPTID) AS F]]></description>
			<content:encoded><![CDATA[<p>SELECT DEPTID,DEPTSAL,TOTSAL,(DEPTSAL*100/TOTSAL)AS PER<br />
FROM</p>
<p>(SELECT DEPTID,SUM(SALARY)AS DEPTSAL,<br />
(SELECT SUM(A.SALARY) AS TOTSAL FROM TBL_EMP A WHERE A.DEPTID=DEPTID) AS TOTSAL</p>
<p>FROM TBL_EMP GROUP BY DEPTID ORDER BY DEPTID) AS F</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Lakshman		</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-the-average-shared-salary-by-each-department/#comment-7039</link>

		<dc:creator><![CDATA[Lakshman]]></dc:creator>
		<pubDate>Sat, 27 Apr 2019 05:37:26 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6597#comment-7039</guid>

					<description><![CDATA[SELECT distinct DeptId,SUM(Salary) OVER (PARTITION BY DeptId) AS DeptTotalSalary,SUM(Salary) over () AS AllTotal 
 ,SUM(Salary) OVER (PARTITION BY DeptId)*100/SUM(Salary) over () AS SharedPercentage
 from tbl_emp]]></description>
			<content:encoded><![CDATA[<p>SELECT distinct DeptId,SUM(Salary) OVER (PARTITION BY DeptId) AS DeptTotalSalary,SUM(Salary) over () AS AllTotal<br />
 ,SUM(Salary) OVER (PARTITION BY DeptId)*100/SUM(Salary) over () AS SharedPercentage<br />
 from tbl_emp</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ankush		</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-the-average-shared-salary-by-each-department/#comment-6728</link>

		<dc:creator><![CDATA[Ankush]]></dc:creator>
		<pubDate>Mon, 01 Oct 2018 06:54:03 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6597#comment-6728</guid>

					<description><![CDATA[Select dept_id, DeptTotalSalary, AllTotal ,ROUND((DeptTotalSalary*100)/AllTotal,3) as percent  from (Select foo.emp_id, foo.emp_name, foo.dept_id, foo.salary, foo2.AllTotal,DeptTotalSalary from tbl_Emp foo
CROSS JOIN 
(select sum(salary) as AllTotal from tbl_Emp )foo2
JOIN 
(Select sum(salary) as DeptTotalSalary, dept_id from tbl_Emp group by dept_id) foo3 ON foo.dept_id = foo3.dept_id) foo4
group by dept_id, DeptTotalSalary, AllTotal]]></description>
			<content:encoded><![CDATA[<p>Select dept_id, DeptTotalSalary, AllTotal ,ROUND((DeptTotalSalary*100)/AllTotal,3) as percent  from (Select foo.emp_id, foo.emp_name, foo.dept_id, foo.salary, foo2.AllTotal,DeptTotalSalary from tbl_Emp foo<br />
CROSS JOIN<br />
(select sum(salary) as AllTotal from tbl_Emp )foo2<br />
JOIN<br />
(Select sum(salary) as DeptTotalSalary, dept_id from tbl_Emp group by dept_id) foo3 ON foo.dept_id = foo3.dept_id) foo4<br />
group by dept_id, DeptTotalSalary, AllTotal</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dinesh.IS		</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-find-the-average-shared-salary-by-each-department/#comment-5960</link>

		<dc:creator><![CDATA[Dinesh.IS]]></dc:creator>
		<pubDate>Wed, 25 Oct 2017 05:28:12 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6597#comment-5960</guid>

					<description><![CDATA[Declare @Total As Numeric(19,2);
Select @Total=Sum(IsNull(Salary,0)) From TBL_EMP
Select DeptID,Sum(IsNull(Salary,0)) As Salary,@Total As AllTotal,Floor(((Sum(IsNull(Salary,0))/IsNull(@Total,0))*100)) As SharedPercentage
From tbl_Emp
Group By DeptID]]></description>
			<content:encoded><![CDATA[<p>Declare @Total As Numeric(19,2);<br />
Select @Total=Sum(IsNull(Salary,0)) From TBL_EMP<br />
Select DeptID,Sum(IsNull(Salary,0)) As Salary,@Total As AllTotal,Floor(((Sum(IsNull(Salary,0))/IsNull(@Total,0))*100)) As SharedPercentage<br />
From tbl_Emp<br />
Group By DeptID</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
