If CASE Statement can be used just nest to 'WHERE' keyword in sql?

HI All,
There are 2 tables,
 dbo.headcount_smart_view & dbo.headcount_user_view,they
are not joined i.e. there is no join between these 2 tables.
 User is trying to create the access restriction on table
dbo.headcount_smart_view as below,
The following case clause is just next to 'WHERE' keyword :
CASE select distinct dbo.headcount_user_view.role_cd from
dbo.headcount_user_view where UPPER(dbo.headcount_user_view.cmt_id) = UPPER(@Variable('BOUSER'))
WHEN 8 THEN dbo.headcount_smart_view.l3_id In (select distinct
dbo.headcount_user_view.divid from dbo.headcount_user_view
where UPPER(dbo.headcount_user_view.cmt_id)=UPPER(@Variable('BOUSER')))
WHEN 9 THEN dbo.headcount_smart_view.l4_id In (select distinct
dbo.headcount_user_view.divid from dbo.headcount_user_view
where UPPER(dbo.headcount_user_view.cmt_id)=UPPER(@Variable('BOUSER')))
ELSE
dbo.headcount_smart_view.l2_id In (select distinct
dbo.headcount_user_view.divid from dbo.headcount_user_view
where UPPER(dbo.headcount_user_view.cmt_id)=UPPER(@Variable('BOUSER')))
END
The user is getting 'syntax error', it seems that the value is not getting compared with any column hence getting the error.
can case statment  be used just next to 'WHERE' keyword in sql? 

I don't have the entire table query...
but could u tell me wil the sql given below work ....
if not, why? and what can be done to make it work ?
SELECT * FROM Customers 
where case select  CustomerID from customers 
when 8 then 'Spock'
when 9 then 'Yedi'
else 'Jedi'
end;
Nope
because of wrong syntax
What the purpose of the case when statement here? I'm not seeing a condition in WHERE. You should use it in a condition like below
SELECT * FROM Customers
where case CustomerID
when 8 then 'Spock'
when 9 then 'Yedi'
else 'Jedi'
end = @SomeParameter
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How can i use just icons on the bookmarks toolbar

    i would like to see all my bookmarks..so how can i use just the icons, and not the text on my bookmark toolbar?

    *Roomy Bookmarks Toolbar: https://addons.mozilla.org/firefox/addon/roomy-bookmarks-toolbar/

  • How can i use the nested table in form 6i

    how can i use the nested table in the form 6i
    ( i.e i want to insert record into the nestred table field ).
    bye siddharth singh

    Nested tables are not supported in Forms 6i, only simple object tables.

  • If i purchase apple tv in the state can i use it in Europe?

    Hello Communitie Pepole.
    My son has the third-generation AppleTV to my surprise it work right off the bat it was perfect, it mirror my MacBook Pro exactly  identical sharp.
    So now my question, is if I decided to purchase apple tv in the state can i use the power voltage in Europe?
    Is it Universal?
    Thank You. Jean-Michel.

    Bienvenue à la communauté Apple.
    Yes, Apple TV can be used anywhere, despite its voltage. The only difference that you will see is the difference between the iTunes store itself and any localised services, such as the NHL channel for example.

  • Can we use formula column in lexical parameter in sql query ...

    hi
    can we use formula column in lexical parameter in sql query ...
    as example
    i want to give
    select * from & c_table
    forumula
    function c_table
    if :p_sort = 1 then
    return 'dept'
    else
    return 'emp'
    end;
    c_table formula column
    is this possible ...
    i have such example in oracle apps reports
    if i try in ordinary report usinf emp table it show error ..
    how we can give formula column...
    please help me in this regard...
    Edited by: 797525 on Feb 20, 2012 9:31 PM

    thanks sir,
    iam not exactly saying select * from &c_table but some thing that like columns in select stmt also will be populated in user_parameters ,there are lot of table select.......from     mtl_demand md,     mtl_system_items msi,     mtl_txn_source_types     mtst,     mtl_item_locations loc     &C_source_from &C_from_cat
    &c_source_from and &c_from_cat formula column and there are defined at report level only ......
    pl/sql code &c_source_from is
    function C_source_fromFormula return VARCHAR2 is
    begin
    if :P_source_type_id = 2 then return(',MTL_SALES_ORDERS mkts');
    else if :P_source_type_id = 3 then return(',GL_CODE_COMBINATIONS gl');
    else if :P_source_type_id = 6 then return(',MTL_GENERIC_DISPOSITIONS mdsp');
    else if :P_source_type_id = 5 then
         if :C_source_where is null then
              return NULL;
         else
              return(',WIP_ENTITIES wip');
         end if;
    else if :P_source_type_id = 8 then return(',MTL_SALES_ORDERS mkts');
    else if :P_source_type_id is null then
    return(',MTL_SALES_ORDERS      mkts,
    MTL_GENERIC_DISPOSITIONS mdsp,
    GL_CODE_COMBINATIONS gl ');
    else null;
    end if; end if; end if; end if; end if; end if;
    RETURN NULL; end;
    this is forumula column i hope that you understand what iam saying
    please help me in this regard....
    thanking you...

  • Can I use Other database as the repository, Sybase/SQL Server? Urgent!!!

    Hi all,
    Can I use Other database as the repository, Sybase/SQL Server? Urgent!!!
    And Can I use other database store business data and sync with lite?
    Thanks ahead!!!

    Jonathan,
    No, it is not possible to use any other database than Oracle (8.1.7) or later .
    Oracle Lite will only work with Oracle.
    Regards

  • Can I use a OID rule for a Query SQL Lov of BIP?

    Hi. Can I use OID data (rules) for a query sql lov in BIP? Ex. filters users/store.
    Thank you.
    R.

    Hi,
    I didn't look at the example, but if you want to secure your application then you should use container managed security. Read this .
    Anyway, you could add this before return "good"; in your login_action()
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("username", user);Then, you can access this from anywhere in the application by using #{sessionScope.username}.
    Pedja

  • Can I use SYSDATE in the WHERE clause to limit the date range of a query

    Hi,
    Basicaly the subject title(Can I use SYSDATE in the WHERE clause to limit the date range of a query) is my question.
    Is this possible and if it is how can I use it. Do I need to join the table to DUAL?
    Thanks in advance.
    Stelios

    As previous poster said, no data is null value, no value. If you want something, you have nvl function to replace null value by an other more significative value in your query.<br>
    <br>
    Nicolas.

  • Can we use SSRS in sharepoint 2013 standard and sql server standard edition

    can we use SSRS in sharepoint 2013 standard and sql server standard edition
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    Yes you can. You do lose some features:
    http://msdn.microsoft.com/en-us/library/cc645993.aspx#Reporting
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Collect statement can be used here?

    In my internal table datatab_lst.
    i have records like below.
    Gsber, seqno, compname ,AMount
    011a ,  001 ,     PMBC , 1000
    011a ,  002 ,     PMBC1, 2000
    011a ,  003 ,     PMBC2, 3000
    011a ,  004 ,     PMBC3, 4000
    011a ,  005 ,     PMBC4, 5000
    130B ,  001 ,     PMBC , 2000
    130B ,  002 ,     PMBC1, 2000
    130B ,  003 ,     PMBC2, 2000
    130B ,  004 ,     PMBC3, 2000
    130B ,  005 ,     PMBC4, 2000
    two set of records with GSBER(011A,130B)
    now i want to merge both@record groups and
    add respective amounts
    Can we use COllect statement here..its not working
    how to use. below code
    loop at datatab_lst.
    collect datatab_lst into xtab_lst.
    endloop.
    not working.
    ambichan

    Hello,
    As Murugesh had said in his previous post, you should have a new internal table with two fields: GSBER and AMOUNT. Since your question was to  were asking to merge the records to get the <i>respective</i> amounts, this is the way to do it.
    But if you are just bothered with finding out what the total amount is regardless of the GSBER value, then you will have to use the approach Murugesh had suggested in his second reply.
    The structure of the new internal table would therefore be determined by what the result you are seeking is.
    Regards,
    Anand Mandalika.

  • Which type of books can I use JUST on my IPOD classic?

    Does anyone know.  I have purchased other books and then can't use them on the classic (just on the tablet).  I know this is an easy answer, but I can't figure it out.
    All the best

    Alas, the Classic doesn't support radio. The basic classic can only play stored audio files. iTunes plays radio by streaming it over the network.

  • Can I use just IAC to create a PDF Binder?

    Hi All,
    I just started looking at the SDK, and normally I'd read it until I found my answer, but the boss wants something done by yesterday.
    I have a stand-alone Visual C++ app that creates a number of different files, such as ACAD drawings, PDF files, Word docs, etc.  My users all have Acrobat Pro 9.  I'd like to be able to use just IAC to get Acrobat to convert a list of files to PDF, then bind them all together in one PDF, all with just one click of a button by the User.  I've looked at the PDFBinder Sample, but this requires making a Plug-In, and then accessing the Plug-In via IAC.  I was hoping there would be a more direct way just using IAC.  The documents imply IAC can give you control "just like a user", and since a user can create a Binder PDF, I was hoping IAC could let me do it, without having to use Plug-Ins or JavaScript.
    So, can anyone point me to any classes in the IAC API that will do this?  Or am I stuck using the sample PDFBinder way?
    Thanks for your time!

    You can do this using the JSObject & JavaScript via IAC - but it's quite difficult from C++ as it was designed for more COM-orientred languages such as VB & .NET.
    It would actually be easier to do it from C++ as a plugin + your own IAC.

  • I bought my ipod in the United States, can i use it in Germany with the germany?, i bought my ipod in the United States, can i use it in Germany with Itunes.de?

    Can I use an Ipod bought in USA in Germany, with Itunes.de?

    I don't see any reason why not.  When connected to the computer it's just a storage device, any music in iTunes on your computer should sync to the iPod where-ever it was purchased.  They're not configured to be region specific.

  • Can I use just as a freeview box

    When I placed my order as far as I can see it just asked if the BT Hub was within 250m of my tv
    Which it is.  Diagonally and in another room.
    So I've got the equipment without the powerline adapters just the ethernet cable which I don't think.  I've just spoken to someone from BT and they're going to request they're sent out to me which will take 7 working days.
    However can I hook the box up and still watch tv without these adapters or must it be connected to the home hub in order to work (to save me having to reconnect then disconnect my old freeview box)?
    Solved!
    Go to Solution.

    purple_kathryn wrote:
    and to answer my own question
    Yes
    Yes it does
    so that's something in the mean time!!
    Please could you elaborate. What works?
    a) Are you able to Tune in and receive all of the Freeview Channels?
    b) Are you able to record programmes manually by pressing the Record Button?
    c) Are you able to Set a programme to be recorded from the EPG? Does it record and can you play it later?
    "Insanity: doing the same thing over and over again and expecting different results." - Albert Einstein

  • TS3992 I have two computers. My iphone is sincronized in my laptop.. can I use just Icloud ion my desktop?

    I have 2 computers. My yphone is registered on my laptop.I am thoinking retire my laptop soon.. For now  Can I use only Icloud on my desktop?

    Icloud does not have restrictions on amount of computers. You can use it on your desktop or laptop or both. Sync with one computer's library comes in to play when you deal with licensed content sync, like music, movies, etc. Icloud only deals with personal info.(contacts, calendars, photos).
    there is another part that for marketing services Apple sells as icloud - itunes in the cloud. Feature that allows you to download your purchses at itunes/app store from any devices. That one is restricted to 5 computers.

Maybe you are looking for