Click to See Complete Forum and Search --> : Combine statments


landslide
01-22-2008, 09:34 AM
I have the following querys SELECT [800], COUNT (800) AS TOTAL
FROM DAYNETTALLY GROUP BY [800] SELECT [805], COUNT (805) AS TOTAL
FROM DAYNETTALLY GROUP BY [800] They both work great but I want to combine them. I want to count both just like it does and then combine both sum into one total. How do I do that?

Zoidal
01-22-2008, 01:41 PM
This may not be the best way to achieve what you want, but it should give you a total of both queries:

CREATE VIEW TotalCount AS
SELECT [800], COUNT (800) AS TOTAL
FROM DAYNETTALLY GROUP BY [800]
UNION
SELECT [805], COUNT (805) AS TOTAL
FROM DAYNETTALLY GROUP BY [800]

SELECT SUM (TOTAL) AS TotalItems
FROM TotalCount

landslide
01-25-2008, 04:41 PM
I tried this but it says enter ethier a select statment or a called proceedure. Any othe Ideas?