• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Please help with this query

map table1.column1 if not null  / spaces else table2.column2 if not null/spaces
else ''

column 1 datatype is in char ----it should be in varchar2
column 2 datatypes is in numeric value ------it should be in varchar2


I have some conditons to satisfy for table 1 as well as table 2 and i need to subset the data and
order it ascending

I have written as

Select(case when table1.column1 is not null and table1.column1 <> ''
then cast( table1.column1 as varchar2(25)) when table2.column2 is not null and
table2.column2  <> '' then cast(table2.column2 as varchar2(25)) else '' end) from table1 where table1.column4 = 018 and table1. column6 between '     ' and  '    ' order by table1.column4, table1.column6 , table2 where table2.column4 = 018 and table2.column6 between ' ' and  ' ' order by table2. column4, table2.colum8

but i am getting error as query end is not correct

1 Solution
You query is malformed.

-- You have this:
                WHEN Table1.Column1 IS NOT NULL AND Table1.Column1 <> ''
                    CAST (Table1.Column1 AS VARCHAR2 (25))
                WHEN Table2.Column2 IS NOT NULL AND Table2.Column2 <> ''
                    CAST (Table2.Column2 AS VARCHAR2 (25))
    FROM   Table1
   WHERE   Table1.Column4 = 018 AND Table1.Column6 BETWEEN '     ' AND '    '
ORDER BY   Table1.Column4, Table1.Column6
-- Followed by this???:
       ,   Table2
   WHERE   Table2.Column4 = 018 AND Table2.Column6 BETWEEN ' ' AND ' '
ORDER BY   Table2.Column4, Table2.Colum8

Open in new window

Devinder Singh VirdiLead Oracle DBA TeamCommented:
In query please correct space between table and column6 "table1. column6" and "order by" and "Where" clause comes two time.
arukuAuthor Commented:
Please help me write this query .......Do i need to use outer join here or how can i specify the conditions for tables

We would gladly try and help you but unfortunately:

1) The requirements are not clear
2) The table definitions are not posted
3) Sample data is unavailable
4) Expected result are not given
Can you provide the table structure and sample data for table1, column1, column2,
and column6 and the structure and sample data for table2, column2, column4, and
column8, and what you want as the output?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now