Joining 2 Database Tables Getting A Sum Value Output
I am wanting to group values together based on which user it assigned to.
Here are the tables:
TABLE1 ID, COMPANY_ID, OPPORTUNITY, DATE_CREATE
TABLE2 ID, ASSIGNED_BY_ID
The two fields that link the two tables together are: TABLE1 > COMPANY_ID
and TABLE2 > ID
Basically I need to do a statement similar to this:
SELECT SUM(OPPORTUNITY) AS total FROM table1 WHERE DATE_CREATE BETWEEN
'$fromdate' AND '$todate' AND ASSIGNED_BY_ID=1 FROM table2
I know I have to join the two tables together where COMPANY_ID from table1
= ID from table2
But I have no idea how to impliment this in the statement.
Any help would be appreciated.
Thanks, Andy
No comments:
Post a Comment