[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • 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 VirdiCommented:
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?

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

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