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 Answer