Re: how to generate the following output in sql ?

From: ddf <oratune_at_msn.com>
Date: Mon, 10 Nov 2008 12:10:45 -0800 (PST)
Message-ID: <54ff76d3-e721-4e03-91ec-31c1193a59dd@e38g2000prn.googlegroups.com>


On Nov 10, 11:22 am, skywalker <mail.supra..._at_gmail.com> wrote:
> I am really really new to sql,please forgive my
> ignorence.
>
> here is my problem
>
> I have this table named mis_outtrack
>
> desc mis_outtrack;
> +-------------+-------------+------+-----+---------+-------+
> | Field       | Type        | Null | Key | Default | Extra |
> +-------------+-------------+------+-----+---------+-------+
> | pub_code    | varchar(3)  | YES  |     | NULL    |       |
> | status_flag | varchar(2)  | YES  |     | NULL    |       |
> | user_id     | varchar(15) | YES  |     | NULL    |       |
> | entry_date  | date        | YES  |     | NULL    |       |
> | pub_date    | date        | YES  |     | NULL    |       |
> +-------------+-------------+------+-----+---------+-------+
>
> select * from mis_outtrack;
> +----------+-------------+---------+------------+------------+
> | pub_code | status_flag | user_id | entry_date | pub_date   |
> +----------+-------------+---------+------------+------------+
> | SND      | RE          | AMY     | 2008-11-01 | 2008-11-01 |
> | SND      | AU          | AMY     | 2008-11-05 | 2008-11-01 |
> | SND      | SE          | AMY     | 2008-11-10 | 2008-11-01 |
> | MND      | RE          | AMY     | 2008-11-03 | 2008-11-02 |
> | MND      | AU          | AMY     | 2008-11-15 | 2008-11-02 |
> | MND      | SE          | AMY     | 2008-11-15 | 2008-11-02 |
> +----------+-------------+---------+------------+------------+
>
> here pub_code is short name for a particular news paper
> useid is the user who is updating the records
> pub_date is the date of publication of that news paper
> and
> entry_date is the date when the user is updating the inserting
> the status of that publication
>
> here RE means recieved
>      AU means audited
>      SE means send
>    there can only be these three status flags
>
> I have to write an sql to display this data in the following format
> ------------------------------------------------------------------------
> pub_code  |entry_date    |entry_date    |entry_date    |pub_date
> |
> (for a    |(when         |(when         |(when         |(publication
> |
> particular|status was RE)|status was AU)|status was SE |date for
> |
> pub_code) |              |              |              |that news
> paper|
> ------------------------------------------------------------------------
> |  SND        2008-11-01    2008-11-05     2008-11-10    2008-11-01
> |  MND        2008-11-03    2008-11-15     2008-11-15
> 2008-11-02
> |
> |
>
> how can I do this in sql
>
>  any help will be appriciated.
>
> Thanks in advance

This appears to be loaded in a MySQL database; why are you asking this question in an Oracle newsgroup?

David Fitzjarrell Received on Mon Nov 10 2008 - 14:10:45 CST

Original text of this message