There are 3 Tables:
Table A
aNo | aName | aCity
A1 | Alex | Ohio
A2 | Nick | LA
A3 | Sam | Seatle
A4 | Rick | Sydney
.
.
.
Table B
bNo | aNo | bType
B1 | A1 | big
B2 | A1 | small
B3 | A1 | small
B1 | A4 | Medium
B2 | A4 | tiny
B3 | A4 | Big
.
.
Table C
aNo | cDate | bNo
A1 | 2011 | B2
A2 | 2006 | B2
A3 | 1993 | B1
A4 | 2018 | B3
A4 | 2013 | B3
A4 | 2002 | B3
.
.
I need to create a view that shows me aName, bType and SUM(TableB.aNo[A1,A4 only])
It should show me something like:
aName | bType | A1 and A4 quantity
Alex | Big | 1
Alex | Medium| Null
Alex | small | 2
Alex | tiny | Null
Rick | Big | 1
Rick | Medium| 1
Rick | small | Null
Rick | Tiny | 1
I tried this:
CREATE VIEW v_A1A4
AS
SELECT
A.aName,
B.bType,
sum(C.aNo) AS Rooms_Total
FROM
A
INNER JOIN Room ON B.aNo = A.aNo
INNER JOIN C ON C.aNo = A.aNo
WHERE C.aNo = 'A1' AND C.aNo = 'A4';
SELECT * FROM v_A1A4;
But this shows the new VIEW table. but all values are NULL.
aName | bType | A1 and A4 quantity
NULL | NULL | NULL
I need to show the quantity of values A1 and A2.
Waht should I do?
b.Anois not a number so it is unclear whatsum()is supposed to be doing.