PostgreSQL interesting issue
There are 5 relations:
Event (etype, description) primary key - etype
City (cname, country, population) primary key - cname
Disaster (cname, dyear, etype, casualties) primary keys - cname, dyear
Prediction (cname, etype, casualties) primary keys - cname, etype
Measures (etype, provider, mcost, percent) primary keys - etype, provider
etype - type of disaster.
provider - police, fire department...
mcost - cost of those providers.
percent - the percent of the providers to avoid casualties.
I need to write a query which finds out 2 successful providers for predicted disasters in a city. The cost for both must not be higher than 1,000,000.
2 Successful providers defined as the max percent possible summed.
I have this so far:
select
from prediction, measures as m1, measures as m2
where m1.provider < m2.provider AND (m1.mcost + m2.mcost <= 1000000)
AND m1.percent + m2.percent >= all (select
I don't know if this partial query right and what to do next.
sql postgresql
add a comment |
There are 5 relations:
Event (etype, description) primary key - etype
City (cname, country, population) primary key - cname
Disaster (cname, dyear, etype, casualties) primary keys - cname, dyear
Prediction (cname, etype, casualties) primary keys - cname, etype
Measures (etype, provider, mcost, percent) primary keys - etype, provider
etype - type of disaster.
provider - police, fire department...
mcost - cost of those providers.
percent - the percent of the providers to avoid casualties.
I need to write a query which finds out 2 successful providers for predicted disasters in a city. The cost for both must not be higher than 1,000,000.
2 Successful providers defined as the max percent possible summed.
I have this so far:
select
from prediction, measures as m1, measures as m2
where m1.provider < m2.provider AND (m1.mcost + m2.mcost <= 1000000)
AND m1.percent + m2.percent >= all (select
I don't know if this partial query right and what to do next.
sql postgresql
"I don't know if this partial query right" --- so run it and see?
– zerkms
Nov 18 '18 at 1:35
Run partial query? why?
– Arthur
Nov 18 '18 at 1:37
please learn to use explicit ANSI standard join syntax e.g. "inner join" "left outer join". Deny yourself the option of placing commas between table names in the from clause.
– Used_By_Already
Nov 18 '18 at 1:53
2
Why would anyone run a partial query? To see if that bit works. If no, fix it. If yes, go on to the next bit.
– Used_By_Already
Nov 18 '18 at 1:57
2
No **** thrown by me. You asked why someone would run a partial query. If you are unwilling to accept advice, fine, but there is no need to toss insults around. Running partial code is a valid approach to SQL.
– Used_By_Already
Nov 18 '18 at 6:32
add a comment |
There are 5 relations:
Event (etype, description) primary key - etype
City (cname, country, population) primary key - cname
Disaster (cname, dyear, etype, casualties) primary keys - cname, dyear
Prediction (cname, etype, casualties) primary keys - cname, etype
Measures (etype, provider, mcost, percent) primary keys - etype, provider
etype - type of disaster.
provider - police, fire department...
mcost - cost of those providers.
percent - the percent of the providers to avoid casualties.
I need to write a query which finds out 2 successful providers for predicted disasters in a city. The cost for both must not be higher than 1,000,000.
2 Successful providers defined as the max percent possible summed.
I have this so far:
select
from prediction, measures as m1, measures as m2
where m1.provider < m2.provider AND (m1.mcost + m2.mcost <= 1000000)
AND m1.percent + m2.percent >= all (select
I don't know if this partial query right and what to do next.
sql postgresql
There are 5 relations:
Event (etype, description) primary key - etype
City (cname, country, population) primary key - cname
Disaster (cname, dyear, etype, casualties) primary keys - cname, dyear
Prediction (cname, etype, casualties) primary keys - cname, etype
Measures (etype, provider, mcost, percent) primary keys - etype, provider
etype - type of disaster.
provider - police, fire department...
mcost - cost of those providers.
percent - the percent of the providers to avoid casualties.
I need to write a query which finds out 2 successful providers for predicted disasters in a city. The cost for both must not be higher than 1,000,000.
2 Successful providers defined as the max percent possible summed.
I have this so far:
select
from prediction, measures as m1, measures as m2
where m1.provider < m2.provider AND (m1.mcost + m2.mcost <= 1000000)
AND m1.percent + m2.percent >= all (select
I don't know if this partial query right and what to do next.
sql postgresql
sql postgresql
asked Nov 18 '18 at 1:31
ArthurArthur
286
286
"I don't know if this partial query right" --- so run it and see?
– zerkms
Nov 18 '18 at 1:35
Run partial query? why?
– Arthur
Nov 18 '18 at 1:37
please learn to use explicit ANSI standard join syntax e.g. "inner join" "left outer join". Deny yourself the option of placing commas between table names in the from clause.
– Used_By_Already
Nov 18 '18 at 1:53
2
Why would anyone run a partial query? To see if that bit works. If no, fix it. If yes, go on to the next bit.
– Used_By_Already
Nov 18 '18 at 1:57
2
No **** thrown by me. You asked why someone would run a partial query. If you are unwilling to accept advice, fine, but there is no need to toss insults around. Running partial code is a valid approach to SQL.
– Used_By_Already
Nov 18 '18 at 6:32
add a comment |
"I don't know if this partial query right" --- so run it and see?
– zerkms
Nov 18 '18 at 1:35
Run partial query? why?
– Arthur
Nov 18 '18 at 1:37
please learn to use explicit ANSI standard join syntax e.g. "inner join" "left outer join". Deny yourself the option of placing commas between table names in the from clause.
– Used_By_Already
Nov 18 '18 at 1:53
2
Why would anyone run a partial query? To see if that bit works. If no, fix it. If yes, go on to the next bit.
– Used_By_Already
Nov 18 '18 at 1:57
2
No **** thrown by me. You asked why someone would run a partial query. If you are unwilling to accept advice, fine, but there is no need to toss insults around. Running partial code is a valid approach to SQL.
– Used_By_Already
Nov 18 '18 at 6:32
"I don't know if this partial query right" --- so run it and see?
– zerkms
Nov 18 '18 at 1:35
"I don't know if this partial query right" --- so run it and see?
– zerkms
Nov 18 '18 at 1:35
Run partial query? why?
– Arthur
Nov 18 '18 at 1:37
Run partial query? why?
– Arthur
Nov 18 '18 at 1:37
please learn to use explicit ANSI standard join syntax e.g. "inner join" "left outer join". Deny yourself the option of placing commas between table names in the from clause.
– Used_By_Already
Nov 18 '18 at 1:53
please learn to use explicit ANSI standard join syntax e.g. "inner join" "left outer join". Deny yourself the option of placing commas between table names in the from clause.
– Used_By_Already
Nov 18 '18 at 1:53
2
2
Why would anyone run a partial query? To see if that bit works. If no, fix it. If yes, go on to the next bit.
– Used_By_Already
Nov 18 '18 at 1:57
Why would anyone run a partial query? To see if that bit works. If no, fix it. If yes, go on to the next bit.
– Used_By_Already
Nov 18 '18 at 1:57
2
2
No **** thrown by me. You asked why someone would run a partial query. If you are unwilling to accept advice, fine, but there is no need to toss insults around. Running partial code is a valid approach to SQL.
– Used_By_Already
Nov 18 '18 at 6:32
No **** thrown by me. You asked why someone would run a partial query. If you are unwilling to accept advice, fine, but there is no need to toss insults around. Running partial code is a valid approach to SQL.
– Used_By_Already
Nov 18 '18 at 6:32
add a comment |
2 Answers
2
active
oldest
votes
Consider calculating two CTEs: all distinct provider pairs and the max percent of each pair. Then join the two CTEs in main query:
WITH provider_pairs AS (
SELECT m1.provider AS provider1, m2.provider AS provider2,
m1.percent + m2.percent AS sum_percent
FROM measures m1
INNER JOIN measures m2 ON m1.provider < m2.provider
INNER JOIN prediction p ON p.etype = m1.etype AND p.etype = m2.etype
WHERE (m1.mcost + m2.mcost <= 1000000)
),
max_pct AS (
SELECT MAX(sum_percent) AS max_percent
FROM provider_pairs p
)
SELECT p.provider1, p.provider2
FROM provider_pairs p
INNER JOIN max_pct m ON p.sum_percent = m.max_percent
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
WITH
defines the CTEs which can be one or comma separated list of more than one. The lastSELECT
statement'sJOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.
– Parfait
Nov 18 '18 at 14:13
add a comment |
If i got the question correct, you are looking for all pairs of providers from measures table whose combined mcost is less than 100000 and whose combined percentage is the maximum
See if the following helps
One way of doing this would be as follows
- Cartesian product the tables and filter out the self join condition
- Sum up the percentage column and sum up the mcost colum
- Filter out summed_up mcost to be <100000
- order by summed_up percentage desc and get the first value.
I created a test case as follows
create table measures(provider varchar(50),mcost int, percent int);
insert into measures values('Police',30000,80);
insert into measures values('Fire Department',50000,40);
insert into measures values('Military',40000,50);
insert into measures values('Medical',45000,70);
select * from (
select row_number() over(order by x.max_percent desc) as rnk
,x.*
from (
select a.provider
,b.provider
,greatest(a.provider,b.provider) as combo_pair
,a.percent+b.percent as summed_percent
,a.mcost+b.mcost as summed_mcost
,max(a.percent+b.percent) over(partition by greatest(a.provider,b.provider)) as max_percent
from measures a
join measures b
on 1=1
where a.provider <> b.provider
and a.mcost+b.mcost <100000 /*Check for the combined cost to be <100000*/
)x
where x.max_percent=x.summed_percent
)y
where y.rnk=1
Updated DEMO
https://dbfiddle.uk/?rdbms=postgres_8.4&fiddle=7db3297721500ee926c590207a1e57e7
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
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%2f53357131%2fpostgresql-interesting-issue%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
Consider calculating two CTEs: all distinct provider pairs and the max percent of each pair. Then join the two CTEs in main query:
WITH provider_pairs AS (
SELECT m1.provider AS provider1, m2.provider AS provider2,
m1.percent + m2.percent AS sum_percent
FROM measures m1
INNER JOIN measures m2 ON m1.provider < m2.provider
INNER JOIN prediction p ON p.etype = m1.etype AND p.etype = m2.etype
WHERE (m1.mcost + m2.mcost <= 1000000)
),
max_pct AS (
SELECT MAX(sum_percent) AS max_percent
FROM provider_pairs p
)
SELECT p.provider1, p.provider2
FROM provider_pairs p
INNER JOIN max_pct m ON p.sum_percent = m.max_percent
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
WITH
defines the CTEs which can be one or comma separated list of more than one. The lastSELECT
statement'sJOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.
– Parfait
Nov 18 '18 at 14:13
add a comment |
Consider calculating two CTEs: all distinct provider pairs and the max percent of each pair. Then join the two CTEs in main query:
WITH provider_pairs AS (
SELECT m1.provider AS provider1, m2.provider AS provider2,
m1.percent + m2.percent AS sum_percent
FROM measures m1
INNER JOIN measures m2 ON m1.provider < m2.provider
INNER JOIN prediction p ON p.etype = m1.etype AND p.etype = m2.etype
WHERE (m1.mcost + m2.mcost <= 1000000)
),
max_pct AS (
SELECT MAX(sum_percent) AS max_percent
FROM provider_pairs p
)
SELECT p.provider1, p.provider2
FROM provider_pairs p
INNER JOIN max_pct m ON p.sum_percent = m.max_percent
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
WITH
defines the CTEs which can be one or comma separated list of more than one. The lastSELECT
statement'sJOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.
– Parfait
Nov 18 '18 at 14:13
add a comment |
Consider calculating two CTEs: all distinct provider pairs and the max percent of each pair. Then join the two CTEs in main query:
WITH provider_pairs AS (
SELECT m1.provider AS provider1, m2.provider AS provider2,
m1.percent + m2.percent AS sum_percent
FROM measures m1
INNER JOIN measures m2 ON m1.provider < m2.provider
INNER JOIN prediction p ON p.etype = m1.etype AND p.etype = m2.etype
WHERE (m1.mcost + m2.mcost <= 1000000)
),
max_pct AS (
SELECT MAX(sum_percent) AS max_percent
FROM provider_pairs p
)
SELECT p.provider1, p.provider2
FROM provider_pairs p
INNER JOIN max_pct m ON p.sum_percent = m.max_percent
Consider calculating two CTEs: all distinct provider pairs and the max percent of each pair. Then join the two CTEs in main query:
WITH provider_pairs AS (
SELECT m1.provider AS provider1, m2.provider AS provider2,
m1.percent + m2.percent AS sum_percent
FROM measures m1
INNER JOIN measures m2 ON m1.provider < m2.provider
INNER JOIN prediction p ON p.etype = m1.etype AND p.etype = m2.etype
WHERE (m1.mcost + m2.mcost <= 1000000)
),
max_pct AS (
SELECT MAX(sum_percent) AS max_percent
FROM provider_pairs p
)
SELECT p.provider1, p.provider2
FROM provider_pairs p
INNER JOIN max_pct m ON p.sum_percent = m.max_percent
answered Nov 18 '18 at 3:13
ParfaitParfait
51.2k84370
51.2k84370
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
WITH
defines the CTEs which can be one or comma separated list of more than one. The lastSELECT
statement'sJOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.
– Parfait
Nov 18 '18 at 14:13
add a comment |
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
WITH
defines the CTEs which can be one or comma separated list of more than one. The lastSELECT
statement'sJOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.
– Parfait
Nov 18 '18 at 14:13
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
The part of max_pct... (rows 9-11) is connected to the WITH clause?
– Arthur
Nov 18 '18 at 4:45
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
And also i can't understand how it'll choose the pair with the max percent
– Arthur
Nov 18 '18 at 6:06
WITH
defines the CTEs which can be one or comma separated list of more than one. The last SELECT
statement's JOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.– Parfait
Nov 18 '18 at 14:13
WITH
defines the CTEs which can be one or comma separated list of more than one. The last SELECT
statement's JOIN
clause chooses the pair with max percent (which can be more than one pair due to ties) as it joins both CTEs.– Parfait
Nov 18 '18 at 14:13
add a comment |
If i got the question correct, you are looking for all pairs of providers from measures table whose combined mcost is less than 100000 and whose combined percentage is the maximum
See if the following helps
One way of doing this would be as follows
- Cartesian product the tables and filter out the self join condition
- Sum up the percentage column and sum up the mcost colum
- Filter out summed_up mcost to be <100000
- order by summed_up percentage desc and get the first value.
I created a test case as follows
create table measures(provider varchar(50),mcost int, percent int);
insert into measures values('Police',30000,80);
insert into measures values('Fire Department',50000,40);
insert into measures values('Military',40000,50);
insert into measures values('Medical',45000,70);
select * from (
select row_number() over(order by x.max_percent desc) as rnk
,x.*
from (
select a.provider
,b.provider
,greatest(a.provider,b.provider) as combo_pair
,a.percent+b.percent as summed_percent
,a.mcost+b.mcost as summed_mcost
,max(a.percent+b.percent) over(partition by greatest(a.provider,b.provider)) as max_percent
from measures a
join measures b
on 1=1
where a.provider <> b.provider
and a.mcost+b.mcost <100000 /*Check for the combined cost to be <100000*/
)x
where x.max_percent=x.summed_percent
)y
where y.rnk=1
Updated DEMO
https://dbfiddle.uk/?rdbms=postgres_8.4&fiddle=7db3297721500ee926c590207a1e57e7
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
add a comment |
If i got the question correct, you are looking for all pairs of providers from measures table whose combined mcost is less than 100000 and whose combined percentage is the maximum
See if the following helps
One way of doing this would be as follows
- Cartesian product the tables and filter out the self join condition
- Sum up the percentage column and sum up the mcost colum
- Filter out summed_up mcost to be <100000
- order by summed_up percentage desc and get the first value.
I created a test case as follows
create table measures(provider varchar(50),mcost int, percent int);
insert into measures values('Police',30000,80);
insert into measures values('Fire Department',50000,40);
insert into measures values('Military',40000,50);
insert into measures values('Medical',45000,70);
select * from (
select row_number() over(order by x.max_percent desc) as rnk
,x.*
from (
select a.provider
,b.provider
,greatest(a.provider,b.provider) as combo_pair
,a.percent+b.percent as summed_percent
,a.mcost+b.mcost as summed_mcost
,max(a.percent+b.percent) over(partition by greatest(a.provider,b.provider)) as max_percent
from measures a
join measures b
on 1=1
where a.provider <> b.provider
and a.mcost+b.mcost <100000 /*Check for the combined cost to be <100000*/
)x
where x.max_percent=x.summed_percent
)y
where y.rnk=1
Updated DEMO
https://dbfiddle.uk/?rdbms=postgres_8.4&fiddle=7db3297721500ee926c590207a1e57e7
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
add a comment |
If i got the question correct, you are looking for all pairs of providers from measures table whose combined mcost is less than 100000 and whose combined percentage is the maximum
See if the following helps
One way of doing this would be as follows
- Cartesian product the tables and filter out the self join condition
- Sum up the percentage column and sum up the mcost colum
- Filter out summed_up mcost to be <100000
- order by summed_up percentage desc and get the first value.
I created a test case as follows
create table measures(provider varchar(50),mcost int, percent int);
insert into measures values('Police',30000,80);
insert into measures values('Fire Department',50000,40);
insert into measures values('Military',40000,50);
insert into measures values('Medical',45000,70);
select * from (
select row_number() over(order by x.max_percent desc) as rnk
,x.*
from (
select a.provider
,b.provider
,greatest(a.provider,b.provider) as combo_pair
,a.percent+b.percent as summed_percent
,a.mcost+b.mcost as summed_mcost
,max(a.percent+b.percent) over(partition by greatest(a.provider,b.provider)) as max_percent
from measures a
join measures b
on 1=1
where a.provider <> b.provider
and a.mcost+b.mcost <100000 /*Check for the combined cost to be <100000*/
)x
where x.max_percent=x.summed_percent
)y
where y.rnk=1
Updated DEMO
https://dbfiddle.uk/?rdbms=postgres_8.4&fiddle=7db3297721500ee926c590207a1e57e7
If i got the question correct, you are looking for all pairs of providers from measures table whose combined mcost is less than 100000 and whose combined percentage is the maximum
See if the following helps
One way of doing this would be as follows
- Cartesian product the tables and filter out the self join condition
- Sum up the percentage column and sum up the mcost colum
- Filter out summed_up mcost to be <100000
- order by summed_up percentage desc and get the first value.
I created a test case as follows
create table measures(provider varchar(50),mcost int, percent int);
insert into measures values('Police',30000,80);
insert into measures values('Fire Department',50000,40);
insert into measures values('Military',40000,50);
insert into measures values('Medical',45000,70);
select * from (
select row_number() over(order by x.max_percent desc) as rnk
,x.*
from (
select a.provider
,b.provider
,greatest(a.provider,b.provider) as combo_pair
,a.percent+b.percent as summed_percent
,a.mcost+b.mcost as summed_mcost
,max(a.percent+b.percent) over(partition by greatest(a.provider,b.provider)) as max_percent
from measures a
join measures b
on 1=1
where a.provider <> b.provider
and a.mcost+b.mcost <100000 /*Check for the combined cost to be <100000*/
)x
where x.max_percent=x.summed_percent
)y
where y.rnk=1
Updated DEMO
https://dbfiddle.uk/?rdbms=postgres_8.4&fiddle=7db3297721500ee926c590207a1e57e7
edited Nov 18 '18 at 5:05
answered Nov 18 '18 at 3:20
George JosephGeorge Joseph
1,47559
1,47559
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
add a comment |
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
i forgot to mention that i am not allowed to use neither order by nor limit here :)
– Arthur
Nov 18 '18 at 4:50
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.
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%2f53357131%2fpostgresql-interesting-issue%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
"I don't know if this partial query right" --- so run it and see?
– zerkms
Nov 18 '18 at 1:35
Run partial query? why?
– Arthur
Nov 18 '18 at 1:37
please learn to use explicit ANSI standard join syntax e.g. "inner join" "left outer join". Deny yourself the option of placing commas between table names in the from clause.
– Used_By_Already
Nov 18 '18 at 1:53
2
Why would anyone run a partial query? To see if that bit works. If no, fix it. If yes, go on to the next bit.
– Used_By_Already
Nov 18 '18 at 1:57
2
No **** thrown by me. You asked why someone would run a partial query. If you are unwilling to accept advice, fine, but there is no need to toss insults around. Running partial code is a valid approach to SQL.
– Used_By_Already
Nov 18 '18 at 6:32