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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:45:41+00:00 2026-06-09T15:45:41+00:00

Ok, so here is my question. Maybe my brain is just fried, but im

  • 0

Ok, so here is my question. Maybe my brain is just fried, but im struggling to wrap my head around this

i have one table(lets say TableA with a set of columns, lets say there names are:

pk1, Pk2, a, b, c,APPLE(has 3 set values from another table), etc (the PK1 and PK2 are primary keys)

and then I have another table(lets say tableB)

PK1(is linked with PK1 on TableA), ag, DOG, sf, STAR(also has a set nr of values),etc

Ok, so now i want to join these 2 tables, thats the easy part. the values in PK1 can repeat, as long as the combination of PK1 and PK2 are unique,and this is the case.

ok, here comes the tricky part. i want get a list of of the distinct combinations of PK1+PK2+a

but i also want to know how many of them are of each type of STAR.

ok, this part is optional(for you bright sparks out there):

and just to really make it tricky, each type of star must then be sub divided into types of APPLES

1) how do i do this?
2) is it possible to do it with just 1 query, i will i have to use something like a cursor?

  • 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-09T15:45:42+00:00Added an answer on June 9, 2026 at 3:45 pm

    What have you tried? Maybe this can help?

    select distinct pk1,pk2,a from tableA
    

    ,

    select tableA.pk1,pk2,a,star,count(*)
    from tableA join tableB on tableA.pk1 = tableB.pk1
    group by tableA.pk1,pk2,a,star
    

    ,

    select tableA.pk1,pk2,a,star,apples,count(*)
    from tableA join tableB on tableA.pk1 = tableB.pk1
    group by tableA.pk1,pk2,a,star,apples
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok so this maybe a simple/silly question but I don't know so here goes:
I asked this question on superuser , but haven't gotten a response. Maybe here
Sorry if this is generic in nature, but I have a question that maybe
I've already posted this question here , but since it's maybe not that Qt-specific,
A simple question here, I have several classes in my code, but only one
Maybe is a often repeated question here, but i can't find anything similar with
maybe it's not so proper to ask this question here... anyway, I'm trying to
This may be a simple question but I can;t find the answer anywhere. Here
Well simple question here (maybe not a simple answer?) Say I have a two
simple question maybe but can't find solution. I have button for refresh/update some contents

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.