So I am not even sure if this is possible but it really would be awesome to learn and to be able to do this.
What I am trying to do is run 3 seperate queries that return a single row of data and create a single table that can then be used in a gridview in asp.net
query 1
SELECT dbo.BOOKINGS.USERID, SUM(dbo.BOOKINGS.APRICE) AS total, COUNT
(dbo.BOOKINGS.USERID) AS bookingcount
FROM dbo.BOOKINGS INNER JOIN
dbo.TOURS ON dbo.BOOKINGS.TOUR = dbo.TOURS.TOUR INNER JOIN
dbo.MAJOR ON dbo.TOURS.MAJOR = dbo.MAJOR.MAJOR
WHERE (dbo.BOOKINGS.BOOKED BETWEEN CONVERT(int, @startdate) AND CONVERT(int,
@enddate)) AND (dbo.MAJOR.SDESCR = 'Cruises') AND
(dbo.BOOKINGS.USERID = @USER) AND (dbo.MAJOR.DIVISION = 'A')
GROUP BY dbo.BOOKINGS.USERID
query 2
SELECT dbo.BOOKINGS.USERID, SUM(dbo.BOOKINGS.APRICE) AS total, COUNT
(dbo.BOOKINGS.USERID) AS bookingcount
FROM dbo.BOOKINGS INNER JOIN
dbo.TOURS ON dbo.BOOKINGS.TOUR = dbo.TOURS.TOUR INNER JOIN
dbo.MAJOR ON dbo.TOURS.MAJOR = dbo.MAJOR.MAJOR
WHERE (dbo.BOOKINGS.BOOKED BETWEEN CONVERT(int, @startdate) AND CONVERT(int,
@enddate)) AND (dbo.MAJOR.SDESCR <> 'Cruises') AND
(dbo.BOOKINGS.USERID = @USER) AND (dbo.MAJOR.DIVISION = 'A')
GROUP BY dbo.BOOKINGS.USERID
query 3
SELECT SUM(dbo.SUBS.AMOUNT) AS total, COUNT(dbo.SUBS.AMOUNT) AS Memberships,
dbo.HOMES.USERID
FROM dbo.HOMES INNER JOIN
dbo.SUBS ON dbo.HOMES.HOME = dbo.SUBS.HOME AND dbo.HOMES.JOINED
= dbo.SUBS.PAIDON
WHERE (dbo.HOMES.JOINED BETWEEN CONVERT(int, @startdate) AND CONVERT(int,
@enddate)) AND (dbo.HOMES.USERID =
@USER)
GROUP BY dbo.HOMES.USERID
all thre queries return a single row with 3 columns
so i figure this could work the only other difficult part is i want to add a new column
query1 userid total1 bookingcount
query2 userid total2 bookingcount
query3 userid total3 memberships
You can do this using a UNION statement, all you have to do is get the 3 select statements to return the same amount of fields and in the same order