Android How to UPDATE an SQLite table from another table using GROUP BY Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to list the tables in a SQLite database file that was opened with ATTACH?How do save an Android Activity state using save instance state?SQL update from one Table to another based on a ID matchHow can I do an UPDATE statement with JOIN in SQL?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I check in SQLite whether a table exists?Update a table using JOIN in SQL Server?How to send an object from one Android Activity to another using Intents?What are the best practices for SQLite on Android?How to pass an object from one activity to another on Android
What does 丫 mean? 丫是什么意思?
New Order #6: Easter Egg
Should a wizard buy fine inks every time he want to copy spells into his spellbook?
How much damage would a cupful of neutron star matter do to the Earth?
If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?
retrieve food groups from food item list
What would you call this weird metallic apparatus that allows you to lift people?
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
Why datecode is SO IMPORTANT to chip manufacturers?
What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?
As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?
What adaptations would allow standard fantasy dwarves to survive in the desert?
How to force a browser when connecting to a specific domain to be https only using only the client machine?
Does any scripture mention that forms of God or Goddess are symbolic?
A term for a woman complaining about things/begging in a cute/childish way
Why do early math courses focus on the cross sections of a cone and not on other 3D objects?
Why are vacuum tubes still used in amateur radios?
Is multiple magic items in one inherently imbalanced?
Why is std::move not [[nodiscard]] in C++20?
Moving a wrapfig vertically to encroach partially on a subsection title
How does the math work when buying airline miles?
AppleTVs create a chatty alternate WiFi network
License to disallow distribution in closed source software, but allow exceptions made by owner?
Show current row "win streak"
Android How to UPDATE an SQLite table from another table using GROUP BY
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to list the tables in a SQLite database file that was opened with ATTACH?How do save an Android Activity state using save instance state?SQL update from one Table to another based on a ID matchHow can I do an UPDATE statement with JOIN in SQL?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I check in SQLite whether a table exists?Update a table using JOIN in SQL Server?How to send an object from one Android Activity to another using Intents?What are the best practices for SQLite on Android?How to pass an object from one activity to another on Android
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
i have an SQLite table with three columns as below
Table A
BOM Date Consumption
salt Mar 8, 2019 0.7
pepper Mar 8, 2019 0.1
Rice Mar 8, 2019 0.8
salt Mar 8, 2019 0.5
pepper Mar 8, 2019 0.2
I want to group the data in the BOM column such that it sums the values for each group in the consumption table to give me a result as below
Table B
BOM Date Consumption
salt Mar 8, 2019 (0.7+0.5)
pepper Mar 8, 2019 (0.1+0.2)
Rice Mar 8, 2019 0.8
my code which is giving me a syntax error for which I am yet to resolve is as below
UPDATE Table_B
SET
Table_B_BOM, Table_B_Date, Table_B_Consumption(
SELECT sum(*)
FROM Table_A
)
add a comment |
i have an SQLite table with three columns as below
Table A
BOM Date Consumption
salt Mar 8, 2019 0.7
pepper Mar 8, 2019 0.1
Rice Mar 8, 2019 0.8
salt Mar 8, 2019 0.5
pepper Mar 8, 2019 0.2
I want to group the data in the BOM column such that it sums the values for each group in the consumption table to give me a result as below
Table B
BOM Date Consumption
salt Mar 8, 2019 (0.7+0.5)
pepper Mar 8, 2019 (0.1+0.2)
Rice Mar 8, 2019 0.8
my code which is giving me a syntax error for which I am yet to resolve is as below
UPDATE Table_B
SET
Table_B_BOM, Table_B_Date, Table_B_Consumption(
SELECT sum(*)
FROM Table_A
)
Do you want to update table b or insert new rows?
– forpas
Mar 8 at 22:55
add a comment |
i have an SQLite table with three columns as below
Table A
BOM Date Consumption
salt Mar 8, 2019 0.7
pepper Mar 8, 2019 0.1
Rice Mar 8, 2019 0.8
salt Mar 8, 2019 0.5
pepper Mar 8, 2019 0.2
I want to group the data in the BOM column such that it sums the values for each group in the consumption table to give me a result as below
Table B
BOM Date Consumption
salt Mar 8, 2019 (0.7+0.5)
pepper Mar 8, 2019 (0.1+0.2)
Rice Mar 8, 2019 0.8
my code which is giving me a syntax error for which I am yet to resolve is as below
UPDATE Table_B
SET
Table_B_BOM, Table_B_Date, Table_B_Consumption(
SELECT sum(*)
FROM Table_A
)
i have an SQLite table with three columns as below
Table A
BOM Date Consumption
salt Mar 8, 2019 0.7
pepper Mar 8, 2019 0.1
Rice Mar 8, 2019 0.8
salt Mar 8, 2019 0.5
pepper Mar 8, 2019 0.2
I want to group the data in the BOM column such that it sums the values for each group in the consumption table to give me a result as below
Table B
BOM Date Consumption
salt Mar 8, 2019 (0.7+0.5)
pepper Mar 8, 2019 (0.1+0.2)
Rice Mar 8, 2019 0.8
my code which is giving me a syntax error for which I am yet to resolve is as below
UPDATE Table_B
SET
Table_B_BOM, Table_B_Date, Table_B_Consumption(
SELECT sum(*)
FROM Table_A
)
asked Mar 8 at 22:44
NoruwaNoruwa
507
507
Do you want to update table b or insert new rows?
– forpas
Mar 8 at 22:55
add a comment |
Do you want to update table b or insert new rows?
– forpas
Mar 8 at 22:55
Do you want to update table b or insert new rows?
– forpas
Mar 8 at 22:55
Do you want to update table b or insert new rows?
– forpas
Mar 8 at 22:55
add a comment |
1 Answer
1
active
oldest
votes
If you want to insert rows in table_b then:
insert into table_b (BOM, Date, Consumption)
select BOM, Date, sum(Consumption)
from table_a
group by BOM, Date
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
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%2f55072022%2fandroid-how-to-update-an-sqlite-table-from-another-table-using-group-by%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to insert rows in table_b then:
insert into table_b (BOM, Date, Consumption)
select BOM, Date, sum(Consumption)
from table_a
group by BOM, Date
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
add a comment |
If you want to insert rows in table_b then:
insert into table_b (BOM, Date, Consumption)
select BOM, Date, sum(Consumption)
from table_a
group by BOM, Date
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
add a comment |
If you want to insert rows in table_b then:
insert into table_b (BOM, Date, Consumption)
select BOM, Date, sum(Consumption)
from table_a
group by BOM, Date
If you want to insert rows in table_b then:
insert into table_b (BOM, Date, Consumption)
select BOM, Date, sum(Consumption)
from table_a
group by BOM, Date
answered Mar 8 at 23:03
forpasforpas
21.8k4830
21.8k4830
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
add a comment |
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
many thanks @ Forpas, worked like a charm.
– Noruwa
Mar 9 at 10:48
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%2f55072022%2fandroid-how-to-update-an-sqlite-table-from-another-table-using-group-by%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
Do you want to update table b or insert new rows?
– forpas
Mar 8 at 22:55