On Sep 1, 4:21 pm, swaroop gowda <swaroop.t...@gmail.com> wrote:
>  If I write a the code like this I am getting 0 count.
>
> SELECT COUNT(*) FROM TABLE_A A WHERE A.flg IN CASE WHEN
> TO_CHAR(to_date('07/08/2010','MM/DD/YYYY'),'YYYY') = '1900' THEN
> 'Y'
> ELSE '('||''''||'Y'||''''||','||''''||'N'||''''||')'
>
> Mainly I need when the date is 1900 then I need to select only Active flg
> 'Y' ELSE I need to get all data.
>
> Please let me know Anything wrong in my statement.
>
> --
> Thanks & Regards
> Swaroop Thailuru Swamy

Oracle should have told you before now what's wrong with the
statement:

SQL> SELECT COUNT(*) FROM TABLE_A A WHERE A.flg IN CASE WHEN
  2  TO_CHAR(dte,'YYYY') = '1900' THEN 'Y'
  3  ELSE '('||''''||'Y'||''''||','||''''||'N'||''''||')' ;
ELSE '('||''''||'Y'||''''||','||''''||'N'||''''||')'
                                                    *
ERROR at line 3:
ORA-00905: missing keyword

Your corrected statement is shown below:

SQL>
SQL> SELECT COUNT(*) FROM TABLE_A A WHERE A.flg IN CASE WHEN
  2  TO_CHAR(dte,'YYYY') = '1900' THEN 'Y'
  3  ELSE '('||''''||'Y'||''''||','||''''||'N'||''''||')' END;

  COUNT(*)
----------
        23

SQL>

I created table_a with a populated date column to return the count.


David Fitzjarrell

-- 
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle-PLSQL@googlegroups.com
To unsubscribe from this group, send email to
oracle-plsql-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en

Reply via email to