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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:52:05+00:00 2026-06-17T18:52:05+00:00

I am having a problem with my query. I have 2 tables: Table 1

  • 0

I am having a problem with my query. I have 2 tables:

Table 1 is AutoCompany it has fields company and CodeCar. CodeCar can be 3 or 4 depending on the type of car that company has.

table 1: AutoCompany

company| CodeCar|  
  jora     3
  jora     4
  jora     3
 ghita     3
 ghita     3
 ghita     4
gheorghe   4
gheorghe   3
gheorghe   3

Table 2 CodeCarCompanies has the codes:

car | codeCar
mers    3
vW      4

I need to select the companies with the count of the occurance of the 2 codeCars
resulting in something like this:

   company  | MERS| VW
   jora        2     1
   ghita       2     1
   gheorghe    2     1

My attempt so far:

 SELECT     COUNT(dbo.AutoComany) AS MERS, dbo.Company, COUNT(dbo.AutoComany.     
 [CodeCar]) AS VW,  

   FROM   dbo.AutoComany FULL OUTER JOIN
                  dbo.AutoComany  ON dbo.АВТОМОБ.КодПредпр = AutoCompany.company
     WHERE     (dbo.CodeCarComapnies.[CodeCar] = 3)
    GROUP BY dbo..company, dbo.CodeCarComapnies.[CodeCar]
    HAVING      (dbo.CodeCarComapnies.[CodeCar] = 4)
  • 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-17T18:52:06+00:00Added an answer on June 17, 2026 at 6:52 pm

    In MS Access, I think you want:

    SELECT codecarcomapnies.car,
           Count(autocompany.codecar) AS CountOfCodeCar
    FROM   autocompany
           INNER JOIN codecarcomapnies
                   ON autocompany.codecar = codecarcomapnies.codecar
    WHERE  autocompany.codecar  IN ( 3, 4 )
    GROUP  BY codecarcomapnies.car; 
    

    The above was built using the MS Access query design window and the Sum Σ button

    Edit re Comment

    SELECT Sum(IIf([autocompany].[codecar]=3,1,0)) AS mers, 
           Sum(IIf([autocompany].[codecar]=4,1,0)) AS vw
    FROM autocompany
    

    Or

    TRANSFORM Count(autocompany.CodeCar) AS CountOfCodeCar
    SELECT "Total" AS Total
    FROM autocompany 
    INNER JOIN CodeCarComapnies 
    ON autocompany.CodeCar = CodeCarComapnies.codeCar
    WHERE autocompany.CodeCar In (3,4)
    GROUP BY "Total"
    PIVOT CodeCarComapnies.car
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m having trouble writing a query, I have two tables. Property Table (property)
I'm having some problems trying to perform a query. I have two tables, one
I'm having a misunderstanding problem with this use of Linq Query I do have
I'm having the following problem with 2 MySQL tables that have a relation: I
I am having a problem filter a query. I have a Contact and a
I'm having an issue with MySQL . I have 2 Tables : Table A
Im having problem trying to join 3 tables, every time I run the query
I am having a problem sorting results from joining tables that have to be
We have a query in our system that has been a problem in the
Having an odd problem with a MySQL query, I can't really figure out how

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.