About Group By

Hi all,
I have to do a report of services performed by month,
returning the date on format mm/yyyy.
The problem is I must format with to_char,
and the ordinance cannot to be done like Character. It must
to be done per date. I group correctly by the columns,
but in the order by clause I use per date, like this:
SELECT department_id, employee_id
TO_CHAR(service_dt, 'mm/yyyy'), COUNT(*)
FROM services
GROUP BY epartment_id, employee_id
TO_CHAR(service_dt, 'mm/yyyy')
ORDER BY department_id, employee_id
service_dt;But the following error occurs:
ORA-00979: not a GROUP BY expression
How can I do to order by date, but showing in the format mm/yyyy?
thanks !!!!

Then try
SELECT department_id,
       employee_id,
       moyr,
       cnt
FROM (SELECT department_id,
             employee_id,
             TO_CHAR(service_dt, 'mm/yyyy') as moyr,
             COUNT(*) as cnt
      FROM services
      GROUP BY department_id,
               employee_id,
               TO_CHAR(service_dt, 'mm/yyyy')) as inline_view
ORDER BY TO_NUMBER(SUBSTR(moyr, 3, 4)||SUBSTR(moyr, 1, 2))  or just readjust your formatting to be yyyy/mm
SELECT department_id,
       employee_id,
       TO_CHAR(service_dt, 'yyyy/mm') as moyr,
       COUNT(*) as cnt
FROM services
GROUP BY department_id,
         employee_id,
         TO_CHAR(service_dt, 'yyyy/mm')
ORDER BY TO_CHAR(service_dt, 'yyyy/mm')-Chuck

Similar Messages

  • A few questions about Group Policy development

    This post was originally in the Windows Development forum. Please note the following:
    This question is not about the application and management of GPOs. It's about how to develop a group policy.
    I know about Group Policy Preferences, please do not provide this as an answer.
    I create a custom group policy for an application.
    Recently the application developers allowed settings to be controlled via policy registry keys, in order to make these settings easier to set for Systems Administrators I have created a GPO. Unfortunately, there aren't that many resources
    I can find that help with Group Policy creation, so:
    Is there an easier way to create and edit admx/adml files rather than just a xml editor? Like a GUI front end?
    The vast majority of this applications settings are just a simple Boolean, is there any way to just use one base presentation element for multiple policies? or do I really have to create a presentation element for every single policy? :/
    As mentioned above, most settings are a simple Boolean, but with an additional enforce parameter. If you "enforce" the setting the user is blocked from changing the value. I was going to peg the setting Boolean to whether the policy was
    Enabled or Disabled and have an enforce check box in the policy itself (this would make it easier to just glance at the configured settings and get an idea). Unfortunately, when you disable a policy you cannot interact
    with its contents, so the enforce check box cannot be toggled. So I have two options:
    Have two policies for each setting eg: Disabled: Load printer settings with the document and
    Enabled: ENFORCE Load printer settings with the document
    OR what I have elected to do is just have the one policy with 2 check-boxes in it, one for the setting and one for the enforcement
    The former is both more complex to write for me and more time consuming to configure for the Administrator, the later is easier for me to write but still annoying to use. So my final question is: can I make it so, even though a policy is disabled, you can
    still toggle settings within the policy?

    Hi Thomas.
    > (this will set the default in the application) and then toggling whether
    > that setting is Enforced (unable for the user to modify it - disabling
    > it in the user interface).
    As said - that's not how policies are intended to work - they are always
    enforced. You are talking about preferences that have an optional
    "enforce" switch :) But doesn't matter for the remainder of this post.
    >  1. The presentation table contains hundreds of presentation tags that
    >     essentially are the same thing. From your response there is no way
    >     to make the GPO any easy to write? I can't just create one generic
    >     presentation that multiple policies can use? I have to create a
    >     presentation for every. single. policy.?
    I'd sugggest to use ADM instead of ADMX. Much easier to write and
    maintain, and copy/paste works very well in ADM :)
    https://msdn.microsoft.com/library/bb742499.aspx
    >  2. Because of how the settings are set, as mentioned in my earlier
    >     post, I have chosen to have each policy contain two check boxes.
    >     Each setting could be set to the following:
    >      1. True
    >      2. False
    >      3. True and Enforced
    >      4. False and Enforced
    What elements you need depends on the registry values your application
    is expecting/checking. I'd suggest a radio button (enabled/disabled) and
    a check box "enforced".
    >     there a way for a Disabled policy to also have settings that can be
    >     modified in Group Policy Management? Or can only Enabled policies be
    >     modified?
    You cannot edit what a disabled GPO does, but you can define it
    (VALUEOFF in ADM files if I recall correctly).
    >     well because it would make it easier for them to read the GPO. But I
    >     think you are saying this is not possible.
    Yes, it isn't. It still - at least to me - is a slight misunderstanding
    of "preferences" versus "policies" :)
    Greetings/Grüße,
    Martin
    Mal ein
    gutes Buch über GPOs lesen?
    Good or bad GPOs? - my blog…
    And if IT bothers me -
    coke bottle design refreshment (-:

  • Question about grouping.

    Hello ,
    I have a problem in grouping my data the way i want , i have 2 tables : Orders & Modifiedorders ,
    the Modifiedorders holds the orderid and some data about how the order is modified , sometimes the orderid
    in the Modifiedorders table can repeat if the data modified is of different types , like modify the quantity or price ..
    Now what i want is to make a report that displays some data from the Orders table and when there are
    record(s) from the modifiedorders table it should be displayed at the left for example , but without repeating the orderid .
    What i tried is creating an outerjoin query between the 2 tables , and using the wizard i created a report with the group left style and had the Orderid as the grouping field , but still the orderid repeats . what should i do ?
    Thanks in advance..

    What i tried is creating an outerjoin query between the 2 tables , and using the wizard i created a report with the group left style and had the Orderid as the grouping field , but still the orderid repeats . what should i do ?You did the right thing. Reuse Reports Wizard.
    What's your query?

  • To get some errors about group policy due to disabled an account

    Hello
    I have an active directory on windows 2012 datacenter. there is a domain on it. it works well.
    Also there is a another AD on another location.  there is another  domain on it. also it works too. 
    there is a trust relationship between 2 domains.
    I disabled an account on first AD server 4 days ago. and then my colleague who manages second AD, notified that started to recieve some errors from eventviewer and have an issue about their group policy.
    the issue event as below;
    The processing of Group Policy failed. Windows could not authenticate to the Active Directory service on a domain controller
    (LDAP Bind function call failed). Look in the details tab for error code and description.
    Event ID 1006
    Event Source Group Policy
    I think the concerning account was built on the second AD for a service. But we don't know how we can find the account on the second AD server in order to change it.
    How can I fix the issue?
    Thanks

    Hi Yavuz,
    >>But we don't know how we can find the account on the second AD server in order to change it.
    What account did we disable? We can check the error code (displayed as a decimal) and error description fields of Event ID 1006 to see if more information can be found.
    Regarding Event ID 1006, the following article can be referred to for more information.
    Event ID 1006 — Group Policy Preprocessing (Active Directory)
    https://technet.microsoft.com/en-us/library/cc727283(v=ws.10).aspx
    Best regards,
    Frank Shen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • I need some help about Group by sql statement.

    Thank you for reading my post
    I am learning more sql and i have a question which is about HR schem.
    how i can show Departments.department_name in the following sql query?
    I want query to show department names along with department IDs.
    SELECT department_id dept_id, job_id, SUM(salary)
    FROM employees
    GROUP BY department_id, job_id ;thanks

    hi
    like this
    SQL> ed
    Wrote file afiedt.buf
      1  select d.department_id dept_id, d.department_name, e.job_id, sum(e.salary)
      2  from employees e, departments d
      3  where e.department_id = d.department_id
      4* group by d.department_id, d.department_name, e.job_id
    SQL> /
       DEPT_ID DEPARTMENT_NAME                JOB_ID     SUM(E.SALARY)
            10 Administration                 AD_ASST             4400
            20 Marketing                      MK_MAN             13000
            20 Marketing                      MK_REP              6000
            30 Purchasing                     PU_MAN             11000
            30 Purchasing                     PU_CLERK           13900
            40 Human Resources                HR_REP              6500
            50 Shipping                       ST_MAN             36400
            50 Shipping                       SH_CLERK           64300
            50 Shipping                       ST_CLERK           55700
            60 IT                             IT_PROG            28800
            70 Public Relations               PR_REP             10000
       DEPT_ID DEPARTMENT_NAME                JOB_ID     SUM(E.SALARY)
            80 Sales                          SA_MAN             61000
            80 Sales                          SA_REP            243500
            90 Executive                      AD_VP              34000
            90 Executive                      AD_PRES            24000
           100 Finance                        FI_MGR             12000
           100 Finance                        FI_ACCOUNT         39600
           110 Accounting                     AC_MGR             12000
           110 Accounting                     AC_ACCOUNT          8300
    19 rows selected.
    SQL>hope this helps
    Taj

  • Any news about Groups in Contacts

    Old issue: Organizing Contacts in Groups.
    Haven't find any useful update on this topic.
    Anyone anything?

    doubtful.  :/
    although, there is rumor of a new update coming around octoberish...no date, butt being talked about.   and said to be most likely around the release of meego1.1
    i hope they do add it.

  • Questions about Groups Wheel & Admin

    OK I have two systems. One is an iMac upgraded from Leopard to Snow Leopard. Its main hard drive has the following owner & group:
    Owner: "system" (Read & Write)
    Group: "admin" (Read & Write)
    But on my Mac Pro's main drive it is like this:
    Owner: "system" (Read & Write)
    Group: "wheel" (Read & Write)
    Note: The Mac Pro was a clean install of Snow Leopard from the full install disk, whereas the iMac was Leopard upgraded to Snow Leopard.
    I have read in some places that in Snow Leopard they use "wheel" instead of "admin", but why would Apple choose to use such a cryptically named group as "wheel" when the use of a logical, sensical term such as "admin" would be much easier to understand to most users? Why is one Snow Leopard computer using the "admin" group whereas another is using the "wheel" group as the default group for the main hard drive? What is the correct group that the main boot drive should have for it (i.e. when you click on the hard drive on the desktop and do "get info" what should it say)?
    I used Migration Utility to copy a user from my MacBook Pro to the Mac Pro. Then I logged in as Root on the Mac Pro and used this method (http://support.apple.com/kb/HT1428) to rename my user directory to be a new shortname, then create a new user with that shortname and point it at that folder (to fix some nagging permissions issues). Then I deleted the old user account. Then I renamed the new user account folder with the old shortname that it used to have, and created a new user with that name. But every time I create a folder it has the "Wheel" group... which seems like a security problem since anything I download into that folder will now be able to SU. Why would that be the default group?
    In the old OS X (like 10.0, 10.1) there used to be "NetInfo Manager" where you could see all the users on a system and all the groups and change all that stuff, if you wanted to. In Leopard there was "Directory Utility" but it had much more limited features. In Snow Leopard, how do I pull up a list of all the users on a system and be able to edit their groups and all that stuff about them?

    DaddieMac wrote:
    V.K. wrote:
    run the following command in terminal
    sudo chown root:admin /
    you'll have to enter your admin password (which you won't see). that's normal.
    This will change the ownership on the hard drive to root:admin.
    Why can't I just "Get Info" on the drive, and set its group to "admin" in there?
    the whole GUI permissions management in Leopard and Snow leopard is very clunky and leaves a lot to be desired.
    Can I just question why Apple has given us the ability to change the group in the "Get Info" box when really it doesn't do anything, and you still have to resort to using the Terminal and typing in non-plain-English commands that are merely relics of an operating system from 40 years ago that somehow still persists in our basement despite its lack of user friendliness?
    what? SU?? wheel is the superuser group. by default only root belongs to it and nobody else. so having a wheel group on a folder does not create security issues.
    what folders exactly have the wheel group? you home folder? as I said, folders created in any folder will inherit the group of that folder so maybe the wheel on your whole drive is doing this.
    Well, even though I went into the "Get Info" box and took off "Wheel" from my root directory, still, when I make new folders on the root level of the drive, it creates them as being group "Wheel." Now, my understanding is that if I download a program and save it INTO that folder, then it would have the ability to execute as root because it will belong to the "Wheel" group -- am I not understanding this correctly? Thanks.
    as I said, the GUI permission management is all messed up. you just keep running into various messed up aspects of it. this is another one. here is what happens.
    when you remove a group completely from permissions using GUI it does not simply go away. it also incredibly changes to wheel.
    you just don't see it because the permissions for the group are changed to none. so, for example, say, you have a file with the group staff and that group has read permissions to the file. you select that group in GUI permissions panel and use "-" to remove it. what should happen is that the group remains the same but it's permissions are set to 0. what does happen is that the group changes to wheel (which has group id=0) and its permissions are set to 0.
    this is definitely a bug and a silly programming error. It's been around since Leopard. I reported it to Apple a long time ago.
    so despite your hate of terminal and unix you are going to have to use them to fix the issue. get used to it. OS X is unix based and sometimes one has to use terminal to fix things. in this case there is no other way to do this. run the terminal command I gave you and it will fix the problem with new (but not already existing) folders at the top level of the hard drive. if you want to change the group on those you'll need to run similar commands for them too.

  • Not sure how to go about grouping this...

    Hello all and thanks in advance for any help you can offer. I'm sorry if this is a bit long winded, but I'm at my wits end.
    I'm using CRXI with SQLserver2000. I'm comfortable with SQL but new to CR which may be causing my problem.
    I've been asked to create a report of accounts closed, by salesperson for the prior 60 days. In addition, I need a count of new accounts brought in by those same salespeople during the same 60 day period. Individually, these two are not the issue.
    The third part is to create a count of new account statii by each sales person for the same new sales so the report would look a bit like this:
    Name     Accounts Closed Since 6/21/08     New Accounts Since 6/21/08
    SJohnson          10                    30
    Status:
    Open: 16
    Closed: 4
    Pending:9
    Declined:1
    JSmith          2                    16
    Status:
    etc.
    etc.
    It's the statii that are causing the trouble because they are all contained in the same field in our data. We'll call it: customer.dbo.info.CurrentStatus.
    There are 7 possible statii: Open, Closed, Declined, Deactivated, Discarded, Pending and ReOpened.
    I can get the sales data out of our sales dbase easily enough, and the statii from our customer data through SQL:
    select S.sRep as Rep, C.CurrentStatus as Status, count (*) as Count
    from sales.dbo.info A
    inner join customer.dbo.info C on S.pkSalesCallID=C.fkSalesCallID
    where
    S.SalesCallDisposition='Sold'
    and
    S.dtSold>'6/21/08'
    group by S.sRep, C.CurrentStatus
    order by S.sRep
    For the closed we have customer.dbo.table.customer.dtClosed This table also includes.sRep so finding the rep, the date closed and the count of the closed is no problem.
    select C.sRep as Rep, count(*) as Count
    from customer.dbo.info C
    where c.sStatus='Closed'
    and c.dtClosed>'6/21/2008'
    What I can't figure out is how in the world to make Crystal Display the data correctly. No matter what configurations, groupings, summaries or counts I try, I keep getting a huge mess when I try to add the various statii in the various sections of the report.
    I get Command as a view (I think) that has 3 columns. Rep, Status and Count.
    Then Command_1 that has Rep and Count. I don't really need that status here because it's only "Closed"
    I would think I'd be able to have my group1 be Rep and drag the Rep column out of the field viewer and that would give me my Rep Name. Then drag out Command_1 Count right beside it to get my Closed count. So far so good. This actually works just fine.
    But if I create a group 2 and summarize by count and try to drag out Status into the Group2 Header, I only get the first of the list, usually closed. If I drag it into the detail, I get something like:
    Closed      4
    Others     2
    Others     2
    And I have ABSOLUTELY no idea why. There is no "others" status in our system.
    Anybody have a clue?
    Thanks again for the help!

    Hi Mike,
    From the sounds of it,  in Crystal Reports:
    1. You should create a group on "Sales Person" (Insert|Group)
    2. For the totals on statii,  you can place those fields in the Details section and insert a summary (right-click on the field and Insert Summary) or create a Running Total (in the Field Explorer).
    3.  For the date range you can either insert a date parameter (in the Field Explorer) and add it to the record selection formula (Report|Selection Formulas|Record...)  or you can hard code the date in the record selection formula.
    The above is a quick overview of how I interpret the requirements for your report.
    Regards,
    Wallie

  • Need info about group permissions

    Hi All,
    I'm confused with OIM group permissions for the following scenario.
    Consider three groups G1,G2,G3 with the following permissions to a particular resource object RO.
    G1 - Has all permission in all places for this RO(resource object,process form,process definition,etc)
    G2 - Has only read permissions in all places for this RO.
    G3 - Doesn't have any permission with respect to this RO.
    And also "Provision by Object Admin Only" is selected for this RO and G1 is an object administartor.
    Now I got the follwing result when I try to provision this resource object.
    case 1:The actor(logged in user) is a member of G1 & G2 ------- Got this error "DOBJ.INSERT_PERMISSION_DENIED.You do not have permission to insert this object " and the provisioning operation is failed.
    case 2:The actor is a member of G1 & G3 ----- Able to provision this resource object.
    Now my question is, in case1 if OIM is denying the operation as G2 doesn't have insert or write permission then how come it is allowing the opertion in case 2 where G3 doesn't have any permission ?
    Is this an expected behaviour or am I missing something ?
    How OIM is handling the permissions for this operation ?
    Thanks in advance.
    Regards,
    NS

    I have the same problem here.. the issue we have is that some users have groups that give permissions, other group that are used by access policies and others for menu visibility. The last two aren't for permissions purposes but they impact on the effective rights of the users, because for example, when users try to revoke resource, OIM says that they don't have permissions. Do you figure a workaround to solve this problem?

  • Question about GROUP BY and HAVING

    Good afternoon,
    I have the following query which returns the desired result (set of students who take CS112 or CS114 but not both). I wanted to "condense" it into a single SELECT statement (if that is at all possible - DDL to execute the statement is provided at the end of this post):
    -- is this select distinct * and its associated where clause absolutely
    -- necessary to obtain the result ?
    select distinct *
      from (
            select s.sno,
                   s.sname,
                   s.age,
                   sum(case when t.cno in ('CS112', 'CS114')
                            then 1
                            else 0
                       end)
                     over (partition by s.sno) as takes_either_or_both
              from student s join take t
                               on (s.sno = t.sno)
      where takes_either_or_both = 1
    ;The following looked reasonable but, unfortunately unsuccessful:
      Window functions not allowed here (in Having Clause)
    select max(s.sno),
           max(s.sname),
           max(s.age),
           sum(case when t.cno in ('CS112', 'CS114')
                    then 1
                    else 0
               end)
             over (partition by s.sno) as takes_either_or_both
      from student s join take t
                       on (s.sno = t.sno)
    group by s.sno
    having sum(case when t.cno in ('CS112', 'CS114')
                    then 1
                    else 0
               end)
             over (partition by s.sno) = 1
    Invalid identifier in Having clause
    select s.sno,
           s.sname,
           s.age,
           sum(case when t.cno in ('CS112', 'CS114')
                    then 1
                    else 0
               end)
             over (partition by s.sno) as takes_either_or_both
      from student s join take t
                       on (s.sno = t.sno)
    group by s.sno, s.sname, s.age
    having takes_either_or_both = 1
    ;I have searched for a document that completely defines the sequence in which the clauses are executed. I have found tidbits here and there but not something complete. I realize that my running into problems like this one is due to my lack of understanding of the sequence and the scope of the clauses that make up a statement. Because of this, I cannot even tell if it is possible to write the above query using a single select statement. Pardon my bit of frustration...
    Thank you for your help,
    John.
    DDL follows.
            /* drop any preexisting tables */
            drop table student;
            drop table courses;
            drop table take;
            /* table of students */
            create table student
            ( sno integer,
              sname varchar(10),
              age integer
            /* table of courses */
            create table courses
            ( cno varchar(5),
              title varchar(10),
              credits integer
            /* table of students and the courses they take */
            create table take
            ( sno integer,
              cno varchar(5)
            insert into student values (1,'AARON',20);
            insert into student values (2,'CHUCK',21);
            insert into student values (3,'DOUG',20);
            insert into student values (4,'MAGGIE',19);
            insert into student values (5,'STEVE',22);
            insert into student values (6,'JING',18);
            insert into student values (7,'BRIAN',21);
            insert into student values (8,'KAY',20);
            insert into student values (9,'GILLIAN',20);
            insert into student values (10,'CHAD',21);
            insert into courses values ('CS112','PHYSICS',4);
            insert into courses values ('CS113','CALCULUS',4);
            insert into courses values ('CS114','HISTORY',4);
            insert into take values (1,'CS112');
            insert into take values (1,'CS113');
            insert into take values (1,'CS114');
            insert into take values (2,'CS112');
            insert into take values (3,'CS112');
            insert into take values (3,'CS114');
            insert into take values (4,'CS112');
            insert into take values (4,'CS113');
            insert into take values (5,'CS113');
            insert into take values (6,'CS113');
            insert into take values (6,'CS114');

    Hi, John,
    Just use the aggregate SUM function.
            select s.sno,
                   s.sname,
                   s.age,
                   sum(case when t.cno in ('CS112', 'CS114')
                            then 1
                            else 0
                       end) as takes_either_or_both
              from student s join take t
                               on (s.sno = t.sno)
           GROUP BY  s.sno,
                    s.sname,
                  s.age
           HAVING  sum(case when t.cno in ('CS112', 'CS114')
                            then 1
                            else 0
                       end)  = 1;Analytic functions are computed after the WHERE- and HAVING clause have been applied. To use the results of an analytic fucntion in a WHERE- or HAVING clause, you have to compute it in a sub-query, and then you can use it in a WHERE- or HAVING clause of a super-query.

  • LR 1.4 Question about Group Edit Capture Time

    Hey guys... working my way through...
    Was wondering -- when I highlight a group of files -- and then go to the Metadata Menu and choose "Edit Capture Time" -- why doesn't it change the date of all the High-Ligghted Photos?
    I am obviously doing something wrong... Can someone please tell me who to di it right?
    THANKS!!

    ambienttroutmask wrote:
    It's a while since I used LR 1, but I think it was the same....to write time changes to RAW files, other than DNG's, you need to enable this in catalog settings. in metadata write changes into propitiatory RAW files. LR is very reluctant to write anything into propitiatory files (and rightly so), best to convert them to DNG's.
    actually - i'm kinda confused.
    all my images are DNG's.
    All I want to do is take a group of photos I took in 2002 [that all have bad dates from different decades somehow] and correct a group of say 130 files at a time to a specific day from all the various days they are mistakenly showing in Capture Time.
    But when I highlight a group of say 30 files and choose to EDIT CAPTURE TIME -- only 1 or maybe a couple of files change -- the rest stay.
    iPhoto allowed me to Batch Change a group of photos from various dates to 1 single date -- but I am getting the impression LR 1.4 does not have the ability to do this.

  • About group by & order by

    SELECT ?move ?road ?submoveslice WHERE {
    ?move <rdf:type> <u:move>.
    ?submoveslice <rdf:type> <u:submove_slice>.
    ?road <rdf:type> <u:road>.
    ?move <u:has_submove> ?submove.
    ?submoveslice <u:submove_at> ?submove.
    ?submove ?relate ?road.
    Hi,using the above sparql statement,i get the following result,
    now i want to grouping them using "move" and ordering using "submoveslice",then get the result : <u:move11> -<u:road1><u:road1><u:road2><u:road3> and <u:move22>-<u:road2><u:road3><u:road1><u:road3>,how to?
    | move | road | submoveslice |
    ================================================
    | <u:move22> | <u:road3> | <u:submove_slice22> |
    | <u:move11> | <u:road3> | <u:submove_slice14> |
    | <u:move22> | <u:road2> | <u:submove_slice21> |
    | <u:move11> | <u:road1> | <u:submove_slice11> |
    | <u:move22> | <u:road1> | <u:submove_slice23> |
    | <u:move11> | <u:road2> | <u:submove_slice13> |
    | <u:move11> | <u:road1> | <u:submove_slice12> |
    | <u:move22> | <u:road3> | <u:submove_slice24> |
    Thank you!!!

    Hi,
    Just to clarify. say we group by ?move variable, then do you want to perform some kind of aggregation on ?road variable?
    From what yo described, looks like you want to concatenate all the road URIs for each ?move variable.
    Thanks,
    Zhe

  • Quick question about GROUP BY

    Hello guys,
    I was wondering if anybody can shed the light on this? It's not very important. I'm just being curious here.
    Imagine I have the following table:
    CREATE TABLE my_table
      n NUMBER(15)
    INSERT INTO my_table SELECT level FROM dual CONNECT BY LEVEL <= 10;I know I can do this
    SELECT 'MY_TABLE',
           (SELECT COUNT(*) FROM my_table)
      FROM dual;To get the name of the table and how many records the table has. Because DUAL table has only one record it will return the correct result.
    But I don't understand why the following query returns the correct result:
    SELECT 'MY_TABLE',
           (SELECT COUNT(*) FROM my_table)
      FROM my_table
    GROUP BY NULL;If I remove the GROUP BY clause, I will have 10 records because my original table has 10 records. But how is it possible to GROUP BY NULL? Actually, you can group by on anything (1, 'HELLO'...) and it will return the correct result.
    So, can anyone tell me how does this make sense??
    Thanks in advance,

    Hi,
    user13117585 wrote:
    Hello guys,
    I was wondering if anybody can shed the light on this? It's not very important. I'm just being curious here.
    Imagine I have the following table:
    CREATE TABLE my_table
    n NUMBER(15)
    INSERT INTO my_table SELECT level FROM dual CONNECT BY LEVEL <= 10;I know I can do this
    SELECT 'MY_TABLE',
    (SELECT COUNT(*) FROM my_table)
    FROM dual;To get the name of the table and how many records the table has. Because DUAL table has only one record it will return the correct result.The fact that dual has only one row explains why the result set has one row. How many columns and what is in those columns doesn't depend on dual in any way.
    But I don't understand why the following query returns the correct result:
    SELECT 'MY_TABLE',
    (SELECT COUNT(*) FROM my_table)
    FROM my_table
    GROUP BY NULL;If I remove the GROUP BY clause, I will have 10 records because my original table has 10 records. But how is it possible to GROUP BY NULL? Actually, you can group by on anything (1, 'HELLO'...) and it will return the correct result.
    So, can anyone tell me how does this make sense??Right. "GROUP BY x" means the output will have 1 row for each distinct value of x. (NULL is treated like a value in this case.) So how many distinct values of NULL are there, or how many distinct values of 1, or 'HELLO', or any constant? There's only 1 value, constants, as the name implies, never change values. So if you GROUP BY any constant, the result set will have exactly one row.
    Thanks in advance,

  • About Group asset and auc

    When i creat asset for auc but after the settelement ,i want to settel this asset in main asset ,when i cerat main asset the required group asset and sub numbe ,so please tell be the relation between main asset ,group asset and auc.
    Regards,
    Pramod Kulkarni.

    1.ASSET CLASSES
    First you create three asset classes for:
    ex:
       ASSET CLASS                              NUMBER RANGE
    1.Plant & machinery                               100-200
    2.Plant& Machinery for  Group Assets-     500-600
    3.Plant & Machinery AUC                       1000-1100
    2.CREATE ASSETS
    First you create  AUCEX; 1000
    THEN POST THE TRANSACTIONS
    3.If you want settele thisauc to fixed asset.
    a. first you create group asset ex:  500
    b. then create Fixed asset  ex: 100
    at the time of creation of Fixed asset , you have to mention in tehasset masster what is the Group asset no:
    for ex;  with in 100 you have to mention 500.
    Then settele the AUC TO fIXED ASSET.
    From here what ever transactions youare osted to Fixed aseet it will update in Group asset also.
    chandra

  • Mapping requirement about grouping with restriction

    Hi,experts:
      There is a complex mapping requirement.
      There are 2 document types(A and B) in the source records.
      I need collect the amount with the document which is type A.
      The source records are as follows:
      Doc_No    Doc_Type   Doc_Itm_No    Amount
       0001        A          0010         3
       0001        A          0020         4
       0002        B          0010         5
       0002        B          0020         6
       0003        A          0010         11
       0003        A          0020         22
       The target records should be:
       Doc_No    Doc_Type   Amount
       0001        A          7
       0003        A          33
       The source and the target data type are the same as follows:
       Documents      1...unbound
       ---Doc_No      1...1
       ---Doc_Type    1...1
       ---Doc_Itm_No  1...1
       ---Amount      1...1
       Q1: How to create the target top node(Documents) with restriction(Doc_Type = 'A')?
           Without the restriction,i can handle it well as follows:
           removecontext(Doc_No)->sort->splitbyvalue(value changed)->collapsecontexts->Documents
       Q2:How to collect the amount?
    Regards
    Ming

    hi ming,
    do this mapping
    Q1: How to create the target top node(Documents) with restriction(Doc_Type = "A")?
    Doc_type-->(if equals "A")>(remove context)-->(createif)----->Documents
    q2. How to collect the amount?
    Doc_type(Documents context) + Amount(Document's context)--->UDF1>(SplitByValue)->Doc_type
    Doc_type(Documents context) + Amount(Document's context)--->UDF2>(SplitByValue)-->Amount
    //****************************UDF1***********************//
    public void get_batch_name(String[] Doc_type,String[] Amount,ResultList result,Container container){  
    //write your code here
         Hashmap myHashmap=new Hashmap();
         for(int i=0; Doc_type.length(), Amount.length())
              if(myHashmap.get(Doc_type<i>==null))
                   {myHashmap.add(Doc_type<i>, Amount<i>);}
              else
                   String amt= amt+myHashmap.get(Doc_type<i>);
                   myHashmap.put(Doc_type<i>,amt);
         Set s=myHashmap.keySet();
         Iterator i=s.iterator();
         while(i.hasNext())
              result.addValue(i.next());
    //********************UDF2***************************//
    public void get_batch_name(String[] Doc_type,String[] Amount,ResultList result,Container container){  
    //write your code here
         Hashmap myHashmap=new Hashmap();
         for(int i=0; Doc_type.length(), Amount.length())
              if(myHashmap.get(Doc_type<i>==null))
                   {myHashmap.add(Doc_type<i>, Amount<i>);}
              else
                   String amt= amt+myHashmap.get(Doc_type<i>);
                   myHashmap.put(Doc_type<i>,amt);
         Arraylist s=myHashmap.values();
         String array[]=s.toArray();     
         while(int i=0;i<array.length();i++)
              result.addValue(array<i>);
    Message was edited by: self
            sudeep dhar

Maybe you are looking for