Question: I have a stored procedure that selects some data in a different format from my original table:

```
USE [VolTracker]
GO

DECLARE @return_value int,
        @offset int

SET @offset = 5

WHILE @offset >= 1 BEGIN
    EXEC    @return_value = [dbo].[sp_getStats]
            @Doffset = @offset,
            @StartTime = --Some Datetime,
            @EndTime = --Some later Datetime,
            @Contract = NULL

    SET @offset = @offset - 1
END

GO

```

This specific example selects all 5 of the tables that I would like it to properly. However, I would like all of these tables joined into one table. How might I go about doing this?

Answer: 
I think the query you want is more like this:

```
SELECT b.categoryid, b.month, b.quarter, b.year, a.amount, c.pname, b.ototal, a.payee, status
FROM paymentnotification a
INNER JOIN monthlyreturns b
   ON a.categoryid = b.categoryid
INNER JOIN users c
   ON b.categoryid = c.categoryid
ORDER BY b.categoryid DESC

```

The way you are doing the correlations doesn't seem clear and may cause problems. Try this one out and see what happens. If its still doing duplicates, perhaps the nature of the data require further filtering.
I don't see any problem.. I get 4 result rows: check this fiddle <http://sqlfiddle.com/#!2/165a22/5>

this is the query I used:

```
SELECT m.categoryid, m.month, m.quarter, m.year,p.amount, u.pname, m.ototal, p.payee, m.status
FROM paymentnotification p JOIN monthlyreturns m ON p.categoryid = m.categoryid
JOIN users u ON u.categoryid = m.categoryid
ORDER BY m.categoryid DESC

```

there are no duplicated rows, just "unique" rows if you consider every column you choose.

Hope it helps