Link to home
Create AccountLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Row Count of Multiple tables in single table

I have a database with several tables and I want to find out how many rows are added each day.
Each table has a field MaintDate which is the date the row was added.  Therefore the query below would give what I want for Table1.

select maintdate,count(maintdate) As NumberofUpdates from Table1 where maintdate >20071001 group by maintdate

There are many tables and I want the output in tabular format e.g

Date           Table1Updates, Table2Updates
01/01/07        78,65
02/01/07        555,666
03/01/07      100,200
Avatar of Ashish Patel
Ashish Patel
Flag of India image

May be you can try Union between select statements like this given below for sample for 2 tables

Select maintdate,count(maintdate) As NumberofUpdates As Table1, NULL As Table2 from Table1 where maintdate >20071001 group by maintdate
UNION
Select maintdate, NULL As Table1, count(maintdate) As NumberofUpdates As Table2 from Table1 where maintdate >20071001 group by maintdate
 
and so on....you can add more statements and note the number of columsn for tables you use.
Avatar of AlHal2

ASKER

Then I won't get the table heading going across.  I'll just have one long column of results.
Avatar of AlHal2

ASKER

Please let me know if I've not been clear.
ASKER CERTIFIED SOLUTION
Avatar of yuching
yuching

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer