I'm trying to create a query for a report but I don't seem to come with the right query for it, I'm kinda new at doing queries and reports, anyway here's what I have.

I have two tables that looks like this:

t1
-------------
|id | date |
| 1 | ..... |
| 2 | ..... |
| 3 | ..... |
| 4 | ..... |
-------------

t2
------------------------
|id | field1| field2 |
| 1 | ..... | ....... |
| 2 | ..... | ....... |
| 3 | ..... | ....... |
| 4 | ..... | ....... |
------------------------

i want to be able to select all fields from t2 based on a date from table 1 there are both linked with by the id, it's supposed to looks like this:
--------------------------------
|id | date | field1 | field2 |
| 1 | ..... | ....... | ....... |
| 2 | ..... | ....... | ....... |
| 3 | ..... | ....... | ....... |
| 4 | ..... | ....... | ....... |
--------------------------------

I think i need to use the inner join but i haven't been able to get the right syntax so if you could point me to the right direction i would really appreciate it

and also how can i add the results of all the rows so that it only displays 1 row, what I'm trying to do is add the totals in each field field1, field2 and then display those results on a bar graph, I'm I taking the right approach for this problem? or maybe this last step can be done by the reports software instead of the query? I'm using CR 2008

thanks guys.

SELECT * FROM t1, t2 WHERE t1.id = t2.id

And for summing up the field contents use:

SELECT sum(field1) as s1, sum(field2 as s2 from t2
commented: NICE POST!! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.