Android How to UPDATE an SQLite table from another table using GROUP BYHow 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
Why do bosons tend to occupy the same state?
Alternative to sending password over mail?
What mechanic is there to disable a threat instead of killing it?
Is the myth that if you can play one instrument, you can learn another instrument with ease true?
What method can I use to design a dungeon difficult enough that the PCs can't make it through without killing them?
What is the most common color to indicate the input-field is disabled?
Short story with a alien planet, government officials must wear exploding medallions
CAST throwing error when run in stored procedure but not when run as raw query
How do I deal with an unproductive colleague in a small company?
How do I gain back my faith in my PhD degree?
Is it possible to create a QR code using text?
How to show a landlord what we have in savings?
Can a virus destroy the BIOS of a modern computer?
Extract rows of a table, that include less than x NULLs
Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?
Expand and Contract
Do scales need to be in alphabetical order?
How to remove strange space symbols in Word
Bullying boss launched a smear campaign and made me unemployable
Dreadful Dastardly Diseases, or Always Atrocious Ailments
Why are the 737's rear doors unusable in a water landing?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Watching something be piped to a file live with tail
What do you call someone who asks many questions?
Android How to UPDATE an SQLite table from another table using GROUP BY
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
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
)
android database sqlite group-by sql-update
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
)
android database sqlite group-by sql-update
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
)
android database sqlite group-by sql-update
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
)
android database sqlite group-by sql-update
android database sqlite group-by sql-update
asked Mar 8 at 22:44
NoruwaNoruwa
477
477
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
19.5k4830
19.5k4830
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