How to rewrite this query without sub query please help me

Hello All Good Evening,
Could you please help me with this query, how can i write this query without sub query, or how can write this query another ways
please help me
select planno, status1, count(*) Counts from
select a.ValetNO PlanNo  ,
case 
     when JoinCode in ('00', '01', '02') then 'Actcess'
     when JoinCode in ('20', '21', '22', '23','38', '39') then
     'Secured' else 'Other' end Status1 ---, COUNT (*)
   from  dbo.ppt a(NOLOCK)  left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO  = b.ValetNO
--group by a.ValetNO
  a group by planno, status1
order by 2
Thank you in Advance
Milan

Whats your objective here? Sorry, am not able to understand the reason for this change. 
Try the below:(Not tested)
;With cte
As
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 ---, COUNT (*)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
select planno, status1, count(*) Counts from cte
a group by planno, status1
order by 2
Even below:
select a.ValetNO PlanNo ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end Status1 , COUNT (1)
from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
Group by a.ValetNO ,
case
when JoinCode in ('00', '01', '02') then 'Actcess'
when JoinCode in ('20', '21', '22', '23','38', '39') then
'Secured' else 'Other' end

Similar Messages

  • HT201363 Hello I forgot my Security question of my Apple ID ? I don't kow what should I do and how to solve this problem ? could you please help  ?

    Hello I forgot my Security question of my Apple ID ? I don't kow what should I do and how to solve this problem ? could you please help  ?

    You need to ask Apple to reset your security questions; ways of contacting them include phoning AppleCare and asking for the Account Security team, clicking here and picking a method for your country, and filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (104569)

  • How to login apple id without payment detail.please help me out

    how to login apple id without payment detail.please help me out

    Unless the instructions on this page are followed when creating an account : Create an iTunes Store, App Store, or iBooks Store account without a credit card or other payment method - Apple Suppor…
    then credit card details will need to be entered before the account can be used to download any item from the store.
    If you are being prompted to review the account then you could see if this post by mountaingoatgirl lets you do without needing to enter credit card details : https://discussions.apple.com/message/24303054#24303054
    If not then you will either have to enter card details (you should be able to remove it after entering it), or create a new account (and follow the instructions on the above link when creating it).

  • How to converse this algorithm!!!please help me!!!

    protected static final int getHash(byte [] data)
    int off = 0;
    int len = data.lenght;
    int k = 147;
    try{
    for(int l = off + len; l > off;)
    k = k * 147 ^ data[--l];
    return k;
    catch(Throwable throwable){
    return k;
    If I have the result of thie method like as: 0x69a6d9dd, how I converse this algorithm to get the original data.(the passed paramether)
    the data's length is no more than 3!!!!

    Post Author: pvierheilig
    CA Forum: Crystal Reports
    Put this in the Color tab formula for the Details section in the Section Editor: If (RecordNumber mod 2) <> 0 Then crSilverelse DefaultAttribute

  • I get the following message when attempting to open some links. I don't know how to interpret this nor correct it. Please help. "A copy of Firefox is already open. Only one copy of Firefox can be open at a time."

    I see some threads (when I google this question) — but do not understand how to correct it. I have a MB Pro, OS X 10.7.1, not a developer — online all day every day managing a small business. Specifically I receive the message more often when attempting to open a link within a tweet (photo, website, other).

    Most people are going to see that message as a result of not properly closing Firefox, and then attempting to reopen Firefox. This problem is most likely to occur on Windows Operating systems, less frequently on Linux and Mac systems but not unheard of on any system.
    Because you are on a Mac, I am referring you directly to an article that has been reworded for each operating system.
    : http://kb.mozillazine.org/Kill_application
    To properly close Firefox on your Mac use "Firefox" button -> Quit Firefox, and not with the "X" in corner of window which simply closes the window and not necessarily Firefox.
    When you get stuck as you have described you must Force Firefox to terminate as described at the end of the article:
    Mac OS X
    :Open Apple Menu and select "Force Quit". For Mac OS X 10.3 and later, you can also use the Activity Monitor found in your "Utilities" folder (Applications -> Utilities -> Activity Monitor).
    <br><small>Please mark "Solved" one answer that will best help others with a similar problem -- hope this was it.</small>

  • How to make outer join in Sub Query?

    Hi!
    I'm facing one problem. Can anyone tell me - how to make outer join in sub query?
    I'm pasting one sample code -
    select e.empno, e.ename,e.job,e.sal,d.deptno,d.dname
    from d_emp e, d_dept d
    where e.deptno(+) = (
                          case
                            when d_dept.deptno = 10
                              then
                                  select deptno
                                  from d_dept
                                  where dname = 'SALES'
                          else
                            d_dept.deptno
                          end
    SQL>
    ERROR at line 15:
    ORA-01799: a column may not be outer-joined to a subqueryHow to resolve this issue?
    Regards.

    And any luck with this?
    SQL> with emp as
      2  (select 100 empno, 'Abcd' ename, 1000 sal, 10 deptno from dual
      3  union all
      4  select 101 empno, 'RRR' ename, 2000 sal, 20 deptno from dual
      5  union all
      6  select 102 empno, 'KKK' ename, 3000 sal, 30 deptno from dual
      7  union all
      8  select 103 empno, 'PPP' ename, 4000 sal, 10 deptno from dual
      9  )
    10  ,dept as
    11  (select 10 deptno, 'FINANCE' dname from dual
    12  union all
    13  select 20 deptno, 'SALES' dname from dual
    14  union all
    15  select 30 deptno, 'IT' dname from dual
    16  union all
    17  select 40 deptno, 'HR' dname from dual
    18  )
    19  select e.empno, e.ename, e.sal, d.deptno, d.dname
    20  from emp e,
    21       (select decode(a.deptno, 10, b.deptno, a.deptno) deptno, decode(a.deptno, 10, b.dname, a.dname) dname
    22      from dept a, (select deptno, dname
    23                    from dept
    24                      where dname = 'SALES'
    25                     ) b
    26       ) d
    27  where e.deptno(+) = d.deptno
    28  /
         EMPNO ENAM        SAL     DEPTNO DNAME
           101 RRR        2000         20 SALES
           101 RRR        2000         20 SALES
           102 KKK        3000         30 IT
                                       40 HR
    SQL> Cheers
    Sarma.

  • How to get this output using sql query?

    Hi,
      How to get this output using sql query?
    Sno Name Age ADD Result
    1 Anil 23 delhi Pass
    2 Shruti 25 bangalor Pass
    3 Arun 21 delhi fail
    4 Sonu 23 pune Pass
    5 Roji 26 hydrabad fail
    6 Anil 28 delhi pass
    Output
    Sno Name Age ADD Result
    1 Anil 23 delhi pass
    28 delhi pass

    Hi Vamshi,
    Your query is not pretty clear.
    write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
    Regards,
    Kannan

  • Filter query with sub query using Dropdown box

    Dear Community,
    I have 2 queries
    1. Main Query with 2 fields:  Project | Project value
    2. Sub Query with 2 fields:  Project group | Project
    Project group can be belonging to number of projects and project can be belong to number of project group (Many to Many).
    My customer wants the main query will open without any filtering.
    When I choose project group from WAD dropdown box, the main query will filtering all the projects that belong to the project group.
    I create WAD; define dropdown box as sub query, and Analysis as main query.
    In the dropdown box I choose "data binding" char and create command "set selection state by binding" (project to project) but it doesnu2019t work. 
    I also try to do this by Replacement Path in the main query, but the variable requires the attribute will be ready for input.
    Thanks a lot
    Yaniv

    I am not sure about your comments on replacement path variable. Without having tried it, here is what I would have attempted:
    The main query needs to use a replacement path variable for Project that is replaced by the results of the sub-query. Sub-query would have a regular input variable for project group. (as a quick test, if you had one analysis item for main query with variable input enabled, it should prompt you to enter Project group).
    Now the drop-down needs to be associated with a javascript function. The javascript function needs to implement command "Set variable state" for the main query data provider to selected value of the drop-down.
    The drop-down should be associated with the sub-query data provider, just used to populate the list of values in drop-down.

  • Detail differentiation between add query,combined query and sub query

    HI
    I would like to know the detail differentiation between add query,combined query and sub query with  universe
    correct me if I a wrong
    Add query : adding of different query from different universe and also with in same universe.
    Combined query : combining query using operators(Union,intersection,minus)with in same universe.
    Sub query :getting results from the sub query and the result serves as the data for main  query within same universe.

    Hi,
    I would advise you to check the product documentation under http://help.sap.com/
    regards
    Steph

  • HT4539 I followed the instructions given to turn my automatic download icon in my iphone 3 and still goes back to off position. Any idea how to fix this issue without getting a new one?

    I followed the instructions given to turn my automatic download icon in my iphone 3 and still goes back to off position. Any idea how to fix this issue without getting a new one?

    Something may have gone amiss on your iPhone.
    To attempt to correct this follow these steps:
    Backup your iPhone using iTunes or iCloud.
    Use iTunes to completely restore your iPhone as Factory new.
    Monitor battery usage to see if it is normal. If not, you may have a hardware problem - if so, contact Apple support.
    Restore your iPhone from your backup above.
    Check battery usage to confirm that it is still normal.

  • After upgrade from SQL Server to SQL server 2012 I cannot show Query Designer ?? Please help

    Hi
    I have installed the required .Net software, but never the less I've got this message. Could you please help me out ?
    Thanx in advance
    Pia 
    TITLE: Microsoft SQL Server Management Studio
    Cannot show Query Designer.
    ADDITIONAL INFORMATION:
    Exception has been thrown by the target of an invocation. (mscorlib)
    Unable to find the requested .Net Framework Data Provider.  It may not be installed. (System.Data)
    BUTTONS:
    OK

    also check
    http://connect.microsoft.com/VisualStudio/feedback/details/652192/visual-studio-2010-add-connection-fails
    mostly machine.config is referring to .net 3.0 assemblies
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • In version 10.1 fcpx how do I edit in proxy, then when I am finished share with optimize footage? It was easy in 10.9 version, but I can't figure this out in 10.1, please help.

    in version 10.1 fcpx how do I edit in proxy, then when I am finished share with optimize footage? It was easy in 10.9 version, but I can't figure this out in 10.1, please help.

    The switch is in the upper right of the viewer.

  • Activation Problem..i Have Registered for the devolopers account and also paid 99 dollars. how do i open my iphone now? please help. this is urgent!

    this morning my iphone showed up a activation problem then it told me to go to devoloper.apple.com and register for the ios developer program.. it costed me 99 dollars. but i did it.. just a moment ago.. how do i access my iphone now? please help me this is real urgent.

    this in my problem too apple say : ur request is pending now and it did not activated yet !    ?  
    what should i do?

  • HT204266 I erase all application of my iphone 4 with erase restore and now it's in restore mode. Now is there any way to restore my iphone without backup. Please help me. I have no need my previous file i just want my i phone ok and work smoothly as new p

    Hi,
    I erase all application of my iphone 4 with erase restore without any backup & i also lose the product serial number. Now it's in restore mode. Now is there any way to restore my iphone without backup. Please help me. I have no need my previous file I just want my iphone4 ok and work smoothly as like new ipone justlike i bought it at first time. I can't restore it. So Please help me to solv this proble.

    See Here  > without the Backup  >  http://support.apple.com/kb/HT4137

  • I down loaded about 100 cds to my library and I can no longer view the downloaded artwork it's shows a black picture or blank. How can I get the artwork back? Please help! Thank you

    I downloaded about 100 cds to my library and I can no longer view the downloaded artwork it's shows a black picture or blank. How can I get the artwork back? Please help! Thank you.

    Hi- apparently I also had a similar moment of madness and thought that 'freeride games' would be fun. Well, so much for that! It added a ton of things to my tool bar, I would like to uninstall it, any suggestions for this one?
    thanks :)

Maybe you are looking for

  • Reminder not working in horizontal mode.

    How to use Reminder "horizontal" mode ?

  • Uregent Requirement, related with export & import of internal table values

    Hello All, According to my requirement I created a copy program(ZRSEIDOC2)   which is copy program of “RSEIDOC2”attached in T Code WE02. and I  created another program ZXXXXXX. Now what I am trying to do is 1.     I  am trying to export the final out

  • Smartforms in Quality certificates

    Hi everybody Can anyone tell that how to use smrtforms in quality certificate? Regards Mohanraj.C

  • Cannot start ddclient.service

    Running sudo systemctl restart ddclient.service I get this error message: Job for ddclient.service failed. See 'systemctl status ddclient.service' and 'journalctl -xn' for details. journal: jul 04 11:04:10 vicente systemd[1]: Starting Dynamic DNS Upd

  • CMP Custom Finder Method Problem

    Hi everybody, I have a problem about CMP Custom Finder Method. I made CMP Entity Bean and deployed. Then, I updated finder section in orion-ejb-jar.xml to add my custom finder query. Here is updating finder section in my orion-ejb-jar.xml. <finder-me