I have two tables that have the exact same fields and I want to join them based on a dummy field I added to them both called join2 = 1.
However when I use the below syntax, it puts it all on one line, where as I want them on seperate lines based on the name field
The syntax I used is:
select a.NAME, a.COUNT1, a.MIN1,a.MAX1,a.SUM1,a.AVG1,
b.NAME, b.COUNT1, b.MIN1,b.MAX1,b.SUM1,b.AVG1
from #AMT_PAYMENTS a
INNER join #cur_bal b on (a.join2 = b.join2)
so the table looks like
name count1 min1 max1 sum1 avg1 name count1 min1 max1 sum1 avg1
instead of just
name count1 min1 max1 sum1 avg1
with the names listed separately vertically
You want to use a UNION statement: