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

  • Home
  • SEARCH
  • 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 8310971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:39:11+00:00 2026-06-08T19:39:11+00:00

I have the following SQL statement (SQLite 3.0) which is joining two tables, the

  • 0

I have the following SQL statement (SQLite 3.0) which is joining two tables, the results are that I have a record per day with totals for the day, but joining it to the language table, it gives me five records per day, one for each language.

SELECT 
re.day,
re.flashcardsAdded,
re.flashcardsTested,
re.flashcardsLearned,
re.totalPoints AS totalForDay,
la.language,
la.total AS totalForLanguage

FROM dpod_site_reportDays AS re
JOIN dpod_site_reportDayLanguageTotals AS la ON re.day=la.day
ORDER BY re.day DESC

However, I want only one record per day and instead of e.g. “french” being data, I want it to be a column name with the total for that language as the data for that column.

How can I change the SQL statement so that I get the language totals in the same record with appropriate field names? e.g.:

day | flashcardsAdded | flashcardsTested | flashcardsLearned | totalForDay | french | german | italian | russian | german

enter image description here

Here are the tables:

CREATE TABLE dpod_site_reportDayLanguageTotals(
day VARCHAR(50), 
language VARCHAR(1024), 
total INT(12), 
extras VARCHAR(1024), 
idCode VARCHAR(1024), 
whenCreated VARCHAR(50), 
whenChanged VARCHAR(50), 
id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE)

CREATE TABLE dpod_site_reportDays(
day VARCHAR(50), 
flashcardsAdded INT(12), 
flashcardsTested INT(12), 
flashcardsLearned INT(12), 
journalPoints INT(12), 
readingPoints INT(12), 
correctionPoints INT(12), 
extrasData TEXT, 
totalPoints INT(12), 
extras VARCHAR(1024), 
idCode VARCHAR(1024), 
whenCreated VARCHAR(50), 
whenChanged VARCHAR(50), 
id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE)
  • 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-06-08T19:39:14+00:00Added an answer on June 8, 2026 at 7:39 pm
    SELECT  
    re.day, 
    re.flashcardsAdded, 
    re.flashcardsTested, 
    re.flashcardsLearned, 
    re.totalPoints AS totalForDay, 
    Sum(CASE la.language WHEN 'french' THEN  la.total ELSE 0 END) AS french, 
    Sum(CASE la.language WHEN 'german' THEN  la.total ELSE 0 END) AS german, 
    Sum(CASE la.language WHEN 'italian' THEN  la.total ELSE 0 END) AS italian, 
    Sum(CASE la.language WHEN 'russian' THEN  la.total ELSE 0 END) AS russian
    
    
    FROM dpod_site_reportDays AS re 
    JOIN dpod_site_reportDayLanguageTotals AS la ON re.day=la.day
    GROUP BY re.day, 
    re.flashcardsAdded, 
    re.flashcardsTested, 
    re.flashcardsLearned, 
    re.totalPoints
    ORDER BY re.day DESC 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have following sql statement that gives me the the first_name and total
I have the following SQL statement which has a very bad performance: SELECT frmInstLastModifiedDate
I have to following SQL Statement that I want to conver to LINQ Select
I need some help writing a SQL statement. I have two tables in a
I have the following SQL statement: USE ws_results_db_2011_09_11_09_06_24;SELECT table_name FROM INFORMATION_SCHEMA.Tables WHERE table_name like
I have the following SQL statement (that is intended for SQL Server): INSERT INTO
I have the following SQL problem. Scenario: I have two tables: Change and ChangeTicket.
I have the following SQL Statement. I need to select the latest record for
I have the following SQL statement which is giving me this error. Error converting
I have the following sql statement, which works perfect and since I'm transferring everything

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.