First of all you need to create a directory on the database.
Create or Replace Directory IMP_DIR as 'Path\Path\';
Ensure the user that will import the file has the privilige to Read & Write on the directory (In case you are not using SYS)
GRANT Read, Write ON DIRECTORY IMP_DIR TO user;
Then, include the directory parameter within the import statement
impdp 'sys AS SYSDBA' file=dump.dmp full=yes log=implog.txt directory=IMP_DIR
Looks like you need a GROUP BY. Your query above done with a GROUP BY
would look like this:
SELECT to_char(auditdate,'YYYY'), count(*)
FROM AuditLog GROUP BY to_char(auditdate,'YYYY');
A similar query can be used for other groupings. For example, here would be a count for each day:
SELECT to_char(auditdate,'MM/DD/YYYY'), count(*)
FROM AuditLog GROUP BY to_char(auditdate,'MM/DD/YYYY');
To do this for each PageTitle, simply add PageTitle like this:
SELECT PageTitle , to_char(auditdate,'MM/DD/YYYY'), count(*)
FROM AuditLog GROUP BY PageTitle, to_char(auditdate,'MM/DD/YYYY');
To pivot the data as you have shown gets a bit more difficult particularly on 10g where there is no PIVOT
. Here is one way to do it on 10g:
SELECT PageTitle
, Sum(DECODE(to_char(AuditDate,'MM/DD/YYYY'),'10/22/2012',1,NULL)) Oct_22
, Sum(DECODE(to_char(AuditDate,'MM/DD/YYYY'),'10/23/2012',1,NULL)) Oct_23
FROM AuditLog GROUP BY PageTitle;
Of course this requires entering all the dates. You can make this a bit easier by generating the query using a query such as this:
SELECT 'SELECT PageTitle ' SQL FROM dual
UNION ALL
SELECT DISTINCT ' , Sum(DECODE(to_char(AuditDate,''MM/DD/YYYY''),'''
|| to_char(AuditDate,'MM/DD/YYYY') || ''',1,NULL)) ' || to_char(AuditDate,'Mon_DD')
FROM AuditLog
UNION ALL
SELECT 'FROM AuditLog GROUP BY PageTitle;' FROM dual;
Here is the sample data I used:
drop table auditlog;
create table AuditLog as (select sysdate auditdate, 'Page 1' PageTitle from dual);
insert into auditlog (select sysdate, 'Page 1' from dual);
insert into auditlog (select sysdate, 'Page 2' from dual);
insert into auditlog (select sysdate, 'Page 3' from dual);
insert into auditlog (select sysdate, 'Page 3' from dual);
insert into auditlog (select sysdate, 'Page 3' from dual);
insert into auditlog (select sysdate+1, 'Page 1' from dual);
insert into auditlog (select sysdate+1, 'Page 1' from dual);
insert into auditlog (select sysdate+1, 'Page 2' from dual);
insert into auditlog (select sysdate+1, 'Page 2' from dual);
insert into auditlog (select sysdate+1, 'Page 3' from dual);
commit;
Best Answer
For something more complex you might need a regular expression, but in this case, the following should suffice.
Sample data.