Display Percentage of grouped SUM to total SUM











up vote
0
down vote

favorite












I currently have results like



total sales | total cost | total profit | department
----------------------------------------------------
100 50 50 A
80 20 60 B
250 120 130 C


Using columns from tables



Invoice_Itemized



itemnum | costper | priceper | quantity | invoice_number
--------------------------------------------------------


Invoice_Totals



invoice_number | datetime
---------------------------


Inventory



itemnum | dept_id
------------------


Departments



 dept_id | description  
----------------------


with the following code



select sum(invoice_itemized.priceper* invoice_itemized.quantity) as "Total Sales",

sum(invoice_itemized.quantity*inventory.cost) as "Total Cost",

sum(invoice_itemized.priceper* invoice_itemized.quantity)-
sum(invoice_itemized.quantity*inventory.cost) as "Total Profit",

departments.description as Department

from invoice_itemized, invoice_totals, inventory, departments

where invoice_itemized.invoice_number=invoice_totals.invoice_number

and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10

and inventory.itemnum=invoice_itemized.itemnum

and inventory.dept_id=departments.dept_id

and departments.description<>'shop use'

and departments.description<>'none'

and departments.description<>'ingredients'

group by departments.description

order by "total profit" desc


I would like results like



total sales | total cost | total profit | percentage total profit | department
-------------------------------------------------------------------------------
100 50 50 20.83 A
80 20 60 25 B
250 120 130 54.17 C


The problem I encounter is that I'm trying to divide a the grouped results of a SUM-SUM by the total of the same SUM-SUM. I've tried something similar to the suggestion made in



Percentage from Total SUM after GROUP BY SQL Server



but that didn't seem to work for me. I was getting binding errors. Any suggestions?










share|improve this question






















  • Why didn't it work? What did you get instead? Side note: Please explicitly list out your JOINs, and put as many conditions in the ON clause as possible, rather than using the comma-separated FROM clause, it's much easier to read and reason about.
    – Clockwork-Muse
    Nov 10 at 0:54










  • Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
    – Gordon Linoff
    Nov 10 at 12:59















up vote
0
down vote

favorite












I currently have results like



total sales | total cost | total profit | department
----------------------------------------------------
100 50 50 A
80 20 60 B
250 120 130 C


Using columns from tables



Invoice_Itemized



itemnum | costper | priceper | quantity | invoice_number
--------------------------------------------------------


Invoice_Totals



invoice_number | datetime
---------------------------


Inventory



itemnum | dept_id
------------------


Departments



 dept_id | description  
----------------------


with the following code



select sum(invoice_itemized.priceper* invoice_itemized.quantity) as "Total Sales",

sum(invoice_itemized.quantity*inventory.cost) as "Total Cost",

sum(invoice_itemized.priceper* invoice_itemized.quantity)-
sum(invoice_itemized.quantity*inventory.cost) as "Total Profit",

departments.description as Department

from invoice_itemized, invoice_totals, inventory, departments

where invoice_itemized.invoice_number=invoice_totals.invoice_number

and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10

and inventory.itemnum=invoice_itemized.itemnum

and inventory.dept_id=departments.dept_id

and departments.description<>'shop use'

and departments.description<>'none'

and departments.description<>'ingredients'

group by departments.description

order by "total profit" desc


I would like results like



total sales | total cost | total profit | percentage total profit | department
-------------------------------------------------------------------------------
100 50 50 20.83 A
80 20 60 25 B
250 120 130 54.17 C


The problem I encounter is that I'm trying to divide a the grouped results of a SUM-SUM by the total of the same SUM-SUM. I've tried something similar to the suggestion made in



Percentage from Total SUM after GROUP BY SQL Server



but that didn't seem to work for me. I was getting binding errors. Any suggestions?










share|improve this question






















  • Why didn't it work? What did you get instead? Side note: Please explicitly list out your JOINs, and put as many conditions in the ON clause as possible, rather than using the comma-separated FROM clause, it's much easier to read and reason about.
    – Clockwork-Muse
    Nov 10 at 0:54










  • Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
    – Gordon Linoff
    Nov 10 at 12:59













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I currently have results like



total sales | total cost | total profit | department
----------------------------------------------------
100 50 50 A
80 20 60 B
250 120 130 C


Using columns from tables



Invoice_Itemized



itemnum | costper | priceper | quantity | invoice_number
--------------------------------------------------------


Invoice_Totals



invoice_number | datetime
---------------------------


Inventory



itemnum | dept_id
------------------


Departments



 dept_id | description  
----------------------


with the following code



select sum(invoice_itemized.priceper* invoice_itemized.quantity) as "Total Sales",

sum(invoice_itemized.quantity*inventory.cost) as "Total Cost",

sum(invoice_itemized.priceper* invoice_itemized.quantity)-
sum(invoice_itemized.quantity*inventory.cost) as "Total Profit",

departments.description as Department

from invoice_itemized, invoice_totals, inventory, departments

where invoice_itemized.invoice_number=invoice_totals.invoice_number

and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10

and inventory.itemnum=invoice_itemized.itemnum

and inventory.dept_id=departments.dept_id

and departments.description<>'shop use'

and departments.description<>'none'

and departments.description<>'ingredients'

group by departments.description

order by "total profit" desc


I would like results like



total sales | total cost | total profit | percentage total profit | department
-------------------------------------------------------------------------------
100 50 50 20.83 A
80 20 60 25 B
250 120 130 54.17 C


The problem I encounter is that I'm trying to divide a the grouped results of a SUM-SUM by the total of the same SUM-SUM. I've tried something similar to the suggestion made in



Percentage from Total SUM after GROUP BY SQL Server



but that didn't seem to work for me. I was getting binding errors. Any suggestions?










share|improve this question













I currently have results like



total sales | total cost | total profit | department
----------------------------------------------------
100 50 50 A
80 20 60 B
250 120 130 C


Using columns from tables



Invoice_Itemized



itemnum | costper | priceper | quantity | invoice_number
--------------------------------------------------------


Invoice_Totals



invoice_number | datetime
---------------------------


Inventory



itemnum | dept_id
------------------


Departments



 dept_id | description  
----------------------


with the following code



select sum(invoice_itemized.priceper* invoice_itemized.quantity) as "Total Sales",

sum(invoice_itemized.quantity*inventory.cost) as "Total Cost",

sum(invoice_itemized.priceper* invoice_itemized.quantity)-
sum(invoice_itemized.quantity*inventory.cost) as "Total Profit",

departments.description as Department

from invoice_itemized, invoice_totals, inventory, departments

where invoice_itemized.invoice_number=invoice_totals.invoice_number

and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10

and inventory.itemnum=invoice_itemized.itemnum

and inventory.dept_id=departments.dept_id

and departments.description<>'shop use'

and departments.description<>'none'

and departments.description<>'ingredients'

group by departments.description

order by "total profit" desc


I would like results like



total sales | total cost | total profit | percentage total profit | department
-------------------------------------------------------------------------------
100 50 50 20.83 A
80 20 60 25 B
250 120 130 54.17 C


The problem I encounter is that I'm trying to divide a the grouped results of a SUM-SUM by the total of the same SUM-SUM. I've tried something similar to the suggestion made in



Percentage from Total SUM after GROUP BY SQL Server



but that didn't seem to work for me. I was getting binding errors. Any suggestions?







sql sql-server tsql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 0:46









Yofi

154




154












  • Why didn't it work? What did you get instead? Side note: Please explicitly list out your JOINs, and put as many conditions in the ON clause as possible, rather than using the comma-separated FROM clause, it's much easier to read and reason about.
    – Clockwork-Muse
    Nov 10 at 0:54










  • Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
    – Gordon Linoff
    Nov 10 at 12:59


















  • Why didn't it work? What did you get instead? Side note: Please explicitly list out your JOINs, and put as many conditions in the ON clause as possible, rather than using the comma-separated FROM clause, it's much easier to read and reason about.
    – Clockwork-Muse
    Nov 10 at 0:54










  • Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
    – Gordon Linoff
    Nov 10 at 12:59
















Why didn't it work? What did you get instead? Side note: Please explicitly list out your JOINs, and put as many conditions in the ON clause as possible, rather than using the comma-separated FROM clause, it's much easier to read and reason about.
– Clockwork-Muse
Nov 10 at 0:54




Why didn't it work? What did you get instead? Side note: Please explicitly list out your JOINs, and put as many conditions in the ON clause as possible, rather than using the comma-separated FROM clause, it's much easier to read and reason about.
– Clockwork-Muse
Nov 10 at 0:54












Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
– Gordon Linoff
Nov 10 at 12:59




Never use commas in the FROM clause. Always use proper, explicit, standard JOIN syntax.
– Gordon Linoff
Nov 10 at 12:59












2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










You can do this with window functions:



with t as (
<your query here>
)
select t.*,
profit * 100.0 / sum(profit) over () as profit_percentage
from t;





share|improve this answer





















  • That worked splendidly! Thank you!
    – Yofi
    Nov 10 at 16:19


















up vote
0
down vote













This should work:



Select q.[Total Sales],
q.[Total Cost],
q.[Total Profit],
q.Total Profit] / q1.Total Profit] as [Percentage Total Profit],
q.Department
from (
select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) q
join (
select sum(t.[Total Profit]) as [Total Profit]
from (select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) t
) q1 on q1.[Total Profit] = q1.[Total Profit]
order by q.[Total Profit] desc





share|improve this answer





















  • Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
    – Yofi
    Nov 10 at 16:15










  • @RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
    – ujawg
    Nov 10 at 16:17










  • That'll do it! Thank you both
    – Yofi
    Nov 10 at 16:34











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235028%2fdisplay-percentage-of-grouped-sum-to-total-sum%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










You can do this with window functions:



with t as (
<your query here>
)
select t.*,
profit * 100.0 / sum(profit) over () as profit_percentage
from t;





share|improve this answer





















  • That worked splendidly! Thank you!
    – Yofi
    Nov 10 at 16:19















up vote
0
down vote



accepted










You can do this with window functions:



with t as (
<your query here>
)
select t.*,
profit * 100.0 / sum(profit) over () as profit_percentage
from t;





share|improve this answer





















  • That worked splendidly! Thank you!
    – Yofi
    Nov 10 at 16:19













up vote
0
down vote



accepted







up vote
0
down vote



accepted






You can do this with window functions:



with t as (
<your query here>
)
select t.*,
profit * 100.0 / sum(profit) over () as profit_percentage
from t;





share|improve this answer












You can do this with window functions:



with t as (
<your query here>
)
select t.*,
profit * 100.0 / sum(profit) over () as profit_percentage
from t;






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 13:01









Gordon Linoff

748k34285391




748k34285391












  • That worked splendidly! Thank you!
    – Yofi
    Nov 10 at 16:19


















  • That worked splendidly! Thank you!
    – Yofi
    Nov 10 at 16:19
















That worked splendidly! Thank you!
– Yofi
Nov 10 at 16:19




That worked splendidly! Thank you!
– Yofi
Nov 10 at 16:19












up vote
0
down vote













This should work:



Select q.[Total Sales],
q.[Total Cost],
q.[Total Profit],
q.Total Profit] / q1.Total Profit] as [Percentage Total Profit],
q.Department
from (
select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) q
join (
select sum(t.[Total Profit]) as [Total Profit]
from (select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) t
) q1 on q1.[Total Profit] = q1.[Total Profit]
order by q.[Total Profit] desc





share|improve this answer





















  • Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
    – Yofi
    Nov 10 at 16:15










  • @RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
    – ujawg
    Nov 10 at 16:17










  • That'll do it! Thank you both
    – Yofi
    Nov 10 at 16:34















up vote
0
down vote













This should work:



Select q.[Total Sales],
q.[Total Cost],
q.[Total Profit],
q.Total Profit] / q1.Total Profit] as [Percentage Total Profit],
q.Department
from (
select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) q
join (
select sum(t.[Total Profit]) as [Total Profit]
from (select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) t
) q1 on q1.[Total Profit] = q1.[Total Profit]
order by q.[Total Profit] desc





share|improve this answer





















  • Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
    – Yofi
    Nov 10 at 16:15










  • @RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
    – ujawg
    Nov 10 at 16:17










  • That'll do it! Thank you both
    – Yofi
    Nov 10 at 16:34













up vote
0
down vote










up vote
0
down vote









This should work:



Select q.[Total Sales],
q.[Total Cost],
q.[Total Profit],
q.Total Profit] / q1.Total Profit] as [Percentage Total Profit],
q.Department
from (
select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) q
join (
select sum(t.[Total Profit]) as [Total Profit]
from (select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) t
) q1 on q1.[Total Profit] = q1.[Total Profit]
order by q.[Total Profit] desc





share|improve this answer












This should work:



Select q.[Total Sales],
q.[Total Cost],
q.[Total Profit],
q.Total Profit] / q1.Total Profit] as [Percentage Total Profit],
q.Department
from (
select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) q
join (
select sum(t.[Total Profit]) as [Total Profit]
from (select sum(invoice_itemized.priceper* invoice_itemized.quantity) as [Total Sales],
sum(invoice_itemized.quantity*inventory.cost) as [Total Cost],
sum(invoice_itemized.priceper* invoice_itemized.quantity) - sum(invoice_itemized.quantity*inventory.cost) as [Total Profit],
departments.description as Department
from invoice_itemized, invoice_totals, inventory, departments
where invoice_itemized.invoice_number=invoice_totals.invoice_number
and year(invoice_totals.datetime)=2018 and month(invoice_totals.datetime)=10
and inventory.itemnum=invoice_itemized.itemnum
and inventory.dept_id=departments.dept_id
and departments.description<>'shop use'
and departments.description<>'none'
and departments.description<>'ingredients'
group by departments.description) t
) q1 on q1.[Total Profit] = q1.[Total Profit]
order by q.[Total Profit] desc






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 2:09









ujawg

966




966












  • Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
    – Yofi
    Nov 10 at 16:15










  • @RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
    – ujawg
    Nov 10 at 16:17










  • That'll do it! Thank you both
    – Yofi
    Nov 10 at 16:34


















  • Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
    – Yofi
    Nov 10 at 16:15










  • @RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
    – ujawg
    Nov 10 at 16:17










  • That'll do it! Thank you both
    – Yofi
    Nov 10 at 16:34
















Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
– Yofi
Nov 10 at 16:15




Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ']'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'q'. Msg 102, Level 15, State 1, Line 35 Incorrect syntax near 'q1'.
– Yofi
Nov 10 at 16:15












@RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
– ujawg
Nov 10 at 16:17




@RedDevil i missed a square bracket :) q.[Total Profit]/q1.[Total Profit]
– ujawg
Nov 10 at 16:17












That'll do it! Thank you both
– Yofi
Nov 10 at 16:34




That'll do it! Thank you both
– Yofi
Nov 10 at 16:34


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235028%2fdisplay-percentage-of-grouped-sum-to-total-sum%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff