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 8564707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:15:33+00:00 2026-06-11T17:15:33+00:00

I am new to sql and In my app I am using sqlite DB’s

  • 0

I am new to sql and In my app I am using sqlite DB’s and I have trouble in creating a query.

I have a DB with column names to be:

Name1  Name2  Score1  Score2 Winner  Aces1  Aces2

Imagine that thse are the stats of a single game, so the same name can be in name 1 or in name 2 in different rows.

I want the following:

a)
Return in a list the player names with a descending number of aces.

For example imagine these rows:

Nick George 39  35  Nick  2   4
Joe  Nick   17  39  Nick  1   0
George Jorge  11  39  Jorge  3  1 

Should give me in a list the following:
//number or aces

George 7
Nick 2
Joe 1
Jorge 1

b)I want the same with number of wins.

c)and the same avg points.

Can you please give me the query?

  • 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-11T17:15:34+00:00Added an answer on June 11, 2026 at 5:15 pm

    Your problem here is a result of storing your data in a denormalised form. If you read up on data normalisation, then you will store your data in a form that is more amenable to producing these queries easily.

    select Winner, COUNT(*) from yourtable group by Winner order by COUNT(*) desc
    

    and

    select name, SUM(aces)
    from
    (
    select Name1 as Name, Score1 as Score, Aces1 as Aces from yourtable
    union all
    select Name2 as Name, Score2 as Score, Aces2 as Aces from yourtable
    ) v
    group by Name
    order by SUM(aces) desc
    

    Average points is left as an exercise for the reader.

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

Sidebar

Related Questions

I have a simple console app using SQL Compact 4.0 and entity frameworks 4.
I'm converting an app to use SQL Server 2008 that is currently using SQLite.
I have an MVC app using Entity Framework and a SQL Server 2008 database.
I am writing some new SQL queries and want to check the query plans
I`m new to sql and have been stuck on the following issue for almost
I'm new to SQL. I have a simple problem with getting the results from
I'm fairly new to SQL, but trying to write quite a complicated query, but
I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have
I'm getting the following error in my MVC2 app using Linq to SQL (I
Im creating an sqlite db in my air for android app inside the following

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.