Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Counting from several tables
union would do it.
( SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table1",
FROM table1
GROUP BY "Date")
union
( SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table2"
FROM table2
GROUP BY "Date")
union
( SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table3"
FROM table3
GROUP BY "Date")
You may have to muck with it a bit and do
( SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table1", FROM table1)
union
( SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table2"
FROM table2)
union
( SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table3"
FROM table3 ) GROUP BY "Date"
Jim
"Keith C. Jakobs, MCP" <elohir_at_hotmail.com> wrote in message
news:%kTK8.16136$153.271725735_at_newssvr14.news.prodigy.com...
> Greetings:
>
> I am trying to make a SQL script that will tell me the the number of
records
> across several tables, listed by date.
>
> I would like my row data to show a range of dates, and the count of
records
> for each table as my columns, though I will transpose row and columns if
> necessary (Can I use row data for column headings)?
>
> I know how to format my date comparisons, and I can do this script
perfectly
> for one table using the script below, but I have no idea how to make one
> script, that will tally the count of all tables, in one output table.
>
> SELECT TO_CHAR(logdate, 'MMDDYY') AS "Date", count(*) AS "Table1"
> FROM table1
> GROUP BY "Date";
>
> I need the counts of Table2, Table3, etc. to also show up in this table.
>
> Can anyone help?
>
> Thanks in advance,
>
> Keith C. Jakobs, MCP
> elohir_at_hotmail.com
>
>
>
Received on Mon Jun 03 2002 - 19:07:17 CDT
![]() |
![]() |