Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    6

    Unanswered: Query to generate a complex report

    Friends,

    We have a small document sharing application using a small Oracle database to keep track of registered users and documents. We have a log table to track the download of documents.

    I want to generate time-bound reports from this table. For example an hourly report on a day basis like :

    HOUR 00 01 02 03 04 05 06 07 08 09 10 ...
    DAY
    10-May 0 0 0 0 1 2 4 5 20 40 100 ..
    11-May 0 0 0 0 1 2 4 5 20 40 100 ...
    ..

    Can I achieve this using a single query ? We use Oracle 8i.

    Any sample query/code would be hugely appreciated.

    Thanks.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Can I achieve this using a single query ?
    Probably, but it is not worth my time to try to do so.
    I'd just use PL/SQL (or PERL).
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Sample table definitions would be helpful!

    I'm guessing you have a table something like this:

    create table t ( dt date, ... );

    where the dt column has the date and time of the downloads.

    You want to put the date part down the page and the time part in hours across the page. The values in each "cell" are counts. Am I right?

    If so, then your query will be something like this:

    select trunc(dt) day
    , sum(decode(to_char(dt,'HH24'),'00',1,0)) "00"
    , sum(decode(to_char(dt,'HH24'),'01',1,0)) "01"
    , sum(decode(to_char(dt,'HH24'),'02',1,0)) "02"
    ...
    from t
    group by trunc(dt);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •