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













0















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
)









share|improve this question






















  • Do you want to update table b or insert new rows?

    – forpas
    Mar 8 at 22:55















0















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
)









share|improve this question






















  • Do you want to update table b or insert new rows?

    – forpas
    Mar 8 at 22:55













0












0








0








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
)









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















1














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





share|improve this answer























  • many thanks @ Forpas, worked like a charm.

    – Noruwa
    Mar 9 at 10:48











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
);



);













draft saved

draft discarded


















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









1














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





share|improve this answer























  • many thanks @ Forpas, worked like a charm.

    – Noruwa
    Mar 9 at 10:48















1














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





share|improve this answer























  • many thanks @ Forpas, worked like a charm.

    – Noruwa
    Mar 9 at 10:48













1












1








1







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





share|improve this answer













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






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 23:03









forpasforpas

19.5k4830




19.5k4830












  • 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





many thanks @ Forpas, worked like a charm.

– Noruwa
Mar 9 at 10:48



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme