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?
sql sql-server tsql
add a comment |
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?
sql sql-server tsql
Why didn't it work? What did you get instead? Side note: Please explicitly list out yourJOIN
s, and put as many conditions in theON
clause as possible, rather than using the comma-separatedFROM
clause, it's much easier to read and reason about.
– Clockwork-Muse
Nov 10 at 0:54
Never use commas in theFROM
clause. Always use proper, explicit, standardJOIN
syntax.
– Gordon Linoff
Nov 10 at 12:59
add a comment |
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?
sql sql-server tsql
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
sql sql-server tsql
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 yourJOIN
s, and put as many conditions in theON
clause as possible, rather than using the comma-separatedFROM
clause, it's much easier to read and reason about.
– Clockwork-Muse
Nov 10 at 0:54
Never use commas in theFROM
clause. Always use proper, explicit, standardJOIN
syntax.
– Gordon Linoff
Nov 10 at 12:59
add a comment |
Why didn't it work? What did you get instead? Side note: Please explicitly list out yourJOIN
s, and put as many conditions in theON
clause as possible, rather than using the comma-separatedFROM
clause, it's much easier to read and reason about.
– Clockwork-Muse
Nov 10 at 0:54
Never use commas in theFROM
clause. Always use proper, explicit, standardJOIN
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
JOIN
s, 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
JOIN
s, 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
add a comment |
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;
That worked splendidly! Thank you!
– Yofi
Nov 10 at 16:19
add a comment |
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
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
add a comment |
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;
That worked splendidly! Thank you!
– Yofi
Nov 10 at 16:19
add a comment |
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;
That worked splendidly! Thank you!
– Yofi
Nov 10 at 16:19
add a comment |
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;
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;
answered Nov 10 at 13:01
Gordon Linoff
748k34285391
748k34285391
That worked splendidly! Thank you!
– Yofi
Nov 10 at 16:19
add a comment |
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
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Why didn't it work? What did you get instead? Side note: Please explicitly list out your
JOIN
s, and put as many conditions in theON
clause as possible, rather than using the comma-separatedFROM
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, standardJOIN
syntax.– Gordon Linoff
Nov 10 at 12:59