Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4557734
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:33:00+00:00 2026-05-21T17:33:00+00:00

I am writing an android application storing workout dates and calories burned. Below is

  • 0

I am writing an android application storing workout dates and calories burned. Below is an example of the data in my table:
this is returned by:

SELECT month, day, calories FROM workouts ORDER BY year ASC, month ASC, day ASC LIMIT 12;

(month | day | calories)
3|2|714
3|3|945
3|4|630
3|10|446
3|16|396
3|20|255
3|22|108
3|23|112     
3|23|169
3|23|2160

the code i’ve written for the above is:

  public Cursor getLastTwelveDays(){
  Cursor c;
  String[] s = {KEY_MONTH, KEY_DAY, KEY_CALORIES};
  String order = KEY_YEAR + " ASC, " + KEY_MONTH + " ASC, " + KEY_DAY + " ASC LIMIT 12" ;
  c = db.query(WORKOUT_TABLE, s, null, null, null, null, order);
  return c;
}

I would like to combine the rows with the same day and month into a single row like so:

3|2|714
3|3|945
3|4|630
3|10|446
3|16|396
3|20|255
3|22|108
3|23|2441    (112 + 169 + 2160)    

Also, it would be nice if it were easy to use with android’s query function.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:33:01+00:00Added an answer on May 21, 2026 at 5:33 pm

    What you are looking for is the group by clause. Use the SUM() method to get the total calories for each date. I believe the group by clause should go before the ORDER BY clause.

    SELECT month, day, SUM(calories) FROM workouts GROUP BY month, day

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing my first Android application, and I have been struggling with this
I'm writing an Android application for RC Cars. It uses a SQLite database, and
I'm writing an Android application that I want to be able to send requests
I'm writing a plugin-enabled android application here. I have 2 applications(2 apk), one is
I am writing an application for Android and am using worker threads to process
I'm writing an application for Android that uses symmetric key encryption to protect sensitive
I am writing an android application that has a webview. On the first load
I am writing an android application for sending email which launches the default mail
I'm currently writing an Android application that should be able to receive push notifications
I'm writing an android application that collects cell signal strengths. I am having trouble

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.