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: 
Assuming I understand what you're trying to do, you are not joining your tables properly. Try joining one at a time

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

```
SELECT M.categoryid, M.month, M.quarter, M.year, M.ototal,

```
   P.amount, P.payee, P.status,

   U.pname

```

FROM paymentnotification AS P

INNER JOIN monthlyreturns AS M ON P.categoryid = M.categoryid

INNER JOIN users AS U ON M.categoryid = U.categoryid

ORDER BY M.categoryid DESC