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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:03:54+00:00 2026-06-14T23:03:54+00:00

I have 2 tables I am working with. Table 1 has 10 categories, entries

  • 0

I have 2 tables I am working with.

Table 1 has 10 categories, entries do not change. unless I change.

Cat_NO | Cause
1      = Animal
2      = Bird
3      = Bear
4      = Dog
5      = Snake
6      = Human
7      = Cow
8      = Car
9      = Fire
10     = Rain

Table 2 has data coming randomly when event occurs. unknown number of record/data.

has following fields

ID     Cat_Code   DateTime    Location    OtherField1   OtherField2

786      7           ...        ...           ...          ...
787      6           ...        ...           ...          ...
789      7           ...        ...           ...          ...
791      1           ...        ...           ...          ...
793      3           ...        ...           ...          ...
794      1           ...        ...           ...          ...
796      4           ...        ...           ...          ...
806      9           ...        ...           ...          ...

I am trying to write query that would give me total for all category in Table 1

Result should be

CAUSE       Total        Hours(I can do this) Field2(this too) Field3(This also)
Animal        2
Bird          0     
Bear          1
Dog           1
Snake         0
Human         1
Cow           2
Car           0
Fire          1
Rain          0

So far I’ve written

SELECT
       Cause
from Table1
  • 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-14T23:03:56+00:00Added an answer on June 14, 2026 at 11:03 pm
    select t1.cause, count(t2.cat_code) as total
    from table1 t1 left outer join table2 t2 on t1.cat_no = t2.cat_code
    group by t1.cause
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have working website in PHP with a MySQL backend which has several tables
I'm working on a project that has categories/subcategories. The database table for this is
Let's say I have two tables in my database. TABLE:Categories ID|CategoryName 01|CategoryA 02|CategoryB 03|CategoryC
We have a database with a tables called 'Sites' This table has the columns,
I have two tables, one called Events and one called Documents. Each table has
I have 2 tables- master and detail table. Master Table has ID column which
I have a working table view on my iphone app, and am implementing a
I have 3 tables I am working with. TableA, TableB, TableC TableA contains the
OK, so I have two tables I'm working with - project and service ,
I have 2 tables that I am working with that use the same column;

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.