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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page