how to fetch last record for the tranactional table which have multiple records of same id in postgresql with join? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceSQL join: selecting the last records in a one-to-many relationshipHow to generate the “create table” sql statement for an existing table in postgreSQLHow to import CSV file data into a PostgreSQL table?How can I drop all the tables in a PostgreSQL database?SQL Query direct or inner joinHow to do an update + join in PostgreSQL?How to do 3 table JOIN in UPDATE query?SQL query, join two tablesselecting latest row of transaction table if row contains some values in MySqlQuery with Subquery in Postgresql
US Healthcare consultation for visitors
What force causes entropy to increase?
Working through the single responsibility principle (SRP) in Python when calls are expensive
Deal with toxic manager when you can't quit
"... to apply for a visa" or "... and applied for a visa"?
Homework question about an engine pulling a train
how can a perfect fourth interval be considered either consonant or dissonant?
Is this wall load bearing? Blueprints and photos attached
How do you keep chess fun when your opponent constantly beats you?
Why doesn't a hydraulic lever violate conservation of energy?
What is the padding with red substance inside of steak packaging?
How to determine omitted units in a publication
Are there continuous functions who are the same in an interval but differ in at least one other point?
How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?
Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)
Keeping a retro style to sci-fi spaceships?
Can I visit the Trinity College (Cambridge) library and see some of their rare books
Python - Fishing Simulator
Do I have Disadvantage attacking with an off-hand weapon?
Am I ethically obligated to go into work on an off day if the reason is sudden?
What's the point in a preamp?
Is every episode of "Where are my Pants?" identical?
How to handle characters who are more educated than the author?
Student Loan from years ago pops up and is taking my salary
how to fetch last record for the tranactional table which have multiple records of same id in postgresql with join?
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceSQL join: selecting the last records in a one-to-many relationshipHow to generate the “create table” sql statement for an existing table in postgreSQLHow to import CSV file data into a PostgreSQL table?How can I drop all the tables in a PostgreSQL database?SQL Query direct or inner joinHow to do an update + join in PostgreSQL?How to do 3 table JOIN in UPDATE query?SQL query, join two tablesselecting latest row of transaction table if row contains some values in MySqlQuery with Subquery in Postgresql
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have two tables one master table named complaints and another transactional table named complaintstaus table.
Below is the main table complaint table
| Complaintid | Status | Reopen | Parent_complaint_id |
|-------------|--------|--------|---------------------|
| 102 | 5 | 1 | 102 |
| 103 | 0 | 0 | 103 |
| 106 | 3 | 0 | 106 |
| 154 | 5 | 1 | 154 |
| 123 | 5 | 1 | 123 |
| 132 | 5 | 1 | 132 |
| 167 | 2 | 0 | 167 |
Below is the second table named complaintstatus
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 2 | 0 |
| 102 | 5 | 0 |
| 102 | 5 | 1 |
| 102 | 0 | 0 |
| 103 | 0 | 0 |
| 106 | 3 | 0 |
| 154 | 2 | 0 |
| 154 | 5 | 0 |
| 154 | 5 | 1 |
| 154 | 0 | 0 |
| 123 | 2 | 0 |
| 123 | 5 | 0 |
| 123 | 5 | 1 |
| 123 | 0 | 0 |
| 167 | 2 | 0 |
Result should be
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 0 | 0 |
| 154 | 0 | 0 |
| 123 | 0 | 0 |
The result I need is total number of reopen =4 and pending count= 3
postgresql join aggregate
add a comment |
I have two tables one master table named complaints and another transactional table named complaintstaus table.
Below is the main table complaint table
| Complaintid | Status | Reopen | Parent_complaint_id |
|-------------|--------|--------|---------------------|
| 102 | 5 | 1 | 102 |
| 103 | 0 | 0 | 103 |
| 106 | 3 | 0 | 106 |
| 154 | 5 | 1 | 154 |
| 123 | 5 | 1 | 123 |
| 132 | 5 | 1 | 132 |
| 167 | 2 | 0 | 167 |
Below is the second table named complaintstatus
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 2 | 0 |
| 102 | 5 | 0 |
| 102 | 5 | 1 |
| 102 | 0 | 0 |
| 103 | 0 | 0 |
| 106 | 3 | 0 |
| 154 | 2 | 0 |
| 154 | 5 | 0 |
| 154 | 5 | 1 |
| 154 | 0 | 0 |
| 123 | 2 | 0 |
| 123 | 5 | 0 |
| 123 | 5 | 1 |
| 123 | 0 | 0 |
| 167 | 2 | 0 |
Result should be
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 0 | 0 |
| 154 | 0 | 0 |
| 123 | 0 | 0 |
The result I need is total number of reopen =4 and pending count= 3
postgresql join aggregate
1
How is pending count calculated? Is it the cumulative sum ofopenstatus
ordered by Parent_id?
– unutbu
Mar 8 at 12:31
yes i need this count
– sumit kundan
Mar 11 at 10:34
add a comment |
I have two tables one master table named complaints and another transactional table named complaintstaus table.
Below is the main table complaint table
| Complaintid | Status | Reopen | Parent_complaint_id |
|-------------|--------|--------|---------------------|
| 102 | 5 | 1 | 102 |
| 103 | 0 | 0 | 103 |
| 106 | 3 | 0 | 106 |
| 154 | 5 | 1 | 154 |
| 123 | 5 | 1 | 123 |
| 132 | 5 | 1 | 132 |
| 167 | 2 | 0 | 167 |
Below is the second table named complaintstatus
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 2 | 0 |
| 102 | 5 | 0 |
| 102 | 5 | 1 |
| 102 | 0 | 0 |
| 103 | 0 | 0 |
| 106 | 3 | 0 |
| 154 | 2 | 0 |
| 154 | 5 | 0 |
| 154 | 5 | 1 |
| 154 | 0 | 0 |
| 123 | 2 | 0 |
| 123 | 5 | 0 |
| 123 | 5 | 1 |
| 123 | 0 | 0 |
| 167 | 2 | 0 |
Result should be
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 0 | 0 |
| 154 | 0 | 0 |
| 123 | 0 | 0 |
The result I need is total number of reopen =4 and pending count= 3
postgresql join aggregate
I have two tables one master table named complaints and another transactional table named complaintstaus table.
Below is the main table complaint table
| Complaintid | Status | Reopen | Parent_complaint_id |
|-------------|--------|--------|---------------------|
| 102 | 5 | 1 | 102 |
| 103 | 0 | 0 | 103 |
| 106 | 3 | 0 | 106 |
| 154 | 5 | 1 | 154 |
| 123 | 5 | 1 | 123 |
| 132 | 5 | 1 | 132 |
| 167 | 2 | 0 | 167 |
Below is the second table named complaintstatus
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 2 | 0 |
| 102 | 5 | 0 |
| 102 | 5 | 1 |
| 102 | 0 | 0 |
| 103 | 0 | 0 |
| 106 | 3 | 0 |
| 154 | 2 | 0 |
| 154 | 5 | 0 |
| 154 | 5 | 1 |
| 154 | 0 | 0 |
| 123 | 2 | 0 |
| 123 | 5 | 0 |
| 123 | 5 | 1 |
| 123 | 0 | 0 |
| 167 | 2 | 0 |
Result should be
| Parent_id | currentstatus | openstatus |
|-----------|---------------|------------|
| 102 | 0 | 0 |
| 154 | 0 | 0 |
| 123 | 0 | 0 |
The result I need is total number of reopen =4 and pending count= 3
postgresql join aggregate
postgresql join aggregate
edited Mar 8 at 12:25
a_horse_with_no_name
308k46471573
308k46471573
asked Mar 8 at 12:21
sumit kundansumit kundan
156
156
1
How is pending count calculated? Is it the cumulative sum ofopenstatus
ordered by Parent_id?
– unutbu
Mar 8 at 12:31
yes i need this count
– sumit kundan
Mar 11 at 10:34
add a comment |
1
How is pending count calculated? Is it the cumulative sum ofopenstatus
ordered by Parent_id?
– unutbu
Mar 8 at 12:31
yes i need this count
– sumit kundan
Mar 11 at 10:34
1
1
How is pending count calculated? Is it the cumulative sum of
openstatus
ordered by Parent_id?– unutbu
Mar 8 at 12:31
How is pending count calculated? Is it the cumulative sum of
openstatus
ordered by Parent_id?– unutbu
Mar 8 at 12:31
yes i need this count
– sumit kundan
Mar 11 at 10:34
yes i need this count
– sumit kundan
Mar 11 at 10:34
add a comment |
0
active
oldest
votes
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%2f55063151%2fhow-to-fetch-last-record-for-the-tranactional-table-which-have-multiple-records%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f55063151%2fhow-to-fetch-last-record-for-the-tranactional-table-which-have-multiple-records%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
1
How is pending count calculated? Is it the cumulative sum of
openstatus
ordered by Parent_id?– unutbu
Mar 8 at 12:31
yes i need this count
– sumit kundan
Mar 11 at 10:34