Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a view for report with column split in two

Status
Not open for further replies.

lana123

Programmer
Aug 20, 2003
79
US
Hi, people.
I wrote a view for my report (Version 9.2.2;Oracle database):
CREATE OR REPLACE VIEW RPT_VIEW1 (RECORD_FK, OPENED_DATE, CLOSED_DATE) AS (
Select RECORD_FK,
DECODE (STATUS_CODE,'OPEN', STATUS_START_DATE) AS OPENED_DATE,
DECODE (STATUS_CODE,'CLOSED', STATUS_START_DATE) AS CLOSED_DATE
From STATUS_TABLE)
Everything looks fine, exept one thing: I get two records instead of one: first with OPENED_DATE (CLOSED is empty), another- with CLOSED_DATE (OPEN is empty) with the same RECORD_FK.
I'll appreciate if somebody shows me how to update my view to get only one record (with OPEN and CLOSED DATE accordingly)
Thanks in advance.
Lana
 
Your code looks fine, the table might be your culprit.

Keep in mind that you should be using the CR supplied ODBC driver, NOT Oracles.

The following should work:

CREATE OR REPLACE VIEW RPT_VIEW1 AS (
Select RECORD_FK,
DECODE (STATUS_CODE,'OPEN', STATUS_START_DATE) AS OPENED_DATE,
DECODE (STATUS_CODE,'CLOSED', STATUS_START_DATE) AS CLOSED_DATE
From STATUS_TABLE)

-k
 
Try

CREATE OR REPLACE VIEW RPT_VIEW1 (RECORD_FK, OPENED_DATE, CLOSED_DATE) AS (
Select RECORD_FK,
max(DECODE (STATUS_CODE,'OPEN', STATUS_START_DATE)) AS OPENED_DATE,
Max(DECODE (STATUS_CODE,'CLOSED', STATUS_START_DATE)) AS CLOSED_DATE
From STATUS_TABLE)
group by RECORD_FK

Ian Waterman
UK Crystal Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top