some group functions
Hi all, I have some data here want to get a desired output like below. I don't know how I could rollup charge_id sales/GST on the same line, respectively.
WITH T AS ( SELECT 'SALES' AS TYPE, 41.7 AS AMOUNT, 51343382 AS CHARGE_ID FROM DUAL UNION SELECT 'GST' AS TYPE, 4.7 AS AMOUNT, 51343382 AS CHARGE_ID FROM DUAL UNION SELECT 'SALES' AS TYPE, 2793.7 AS AMOUNT, 51343383 AS CHARGE_ID FROM DUAL UNION SELECT 'GST' AS TYPE, 279.37 AS AMOUNT, 51343383 AS CHARGE_ID FROM DUAL UNION SELECT 'GST' AS TYPE, 279.37 AS AMOUNT, 51343384 AS CHARGE_ID FROM DUAL UNION SELECT 'GST' AS TYPE, -250 AS AMOUNT, 51343384 AS CHARGE_ID FROM DUAL UNION SELECT 'SALES' AS TYPE, 2793.70 AS AMOUNT, 51343384 AS CHARGE_ID FROM DUAL UNION SELECT 'RETURN' AS TYPE, -2500 AS AMOUNT, 51343384 AS CHARGE_ID FROM DUAL UNION SELECT 'GST' AS TYPE, 69.80 AS AMOUNT, 51343385 AS CHARGE_ID FROM DUAL UNION SELECT 'SALES' AS TYPE, 698 AS AMOUNT, 51343385 AS CHARGE_ID FROM DUAL UNION SELECT 'RETURN' AS TYPE, -697.90 AS AMOUNT, 51446663 AS CHARGE_ID FROM DUAL UNION SELECT 'GST' AS TYPE, -69.80 AS AMOUNT, 51446663 AS CHARGE_ID FROM DUAL ) SELECT CHARGE_ID, DECODE(TYPE, 'GST', AMOUNT, 0) TOTAL_GST, DECODE(TYPE, 'GST', 0, AMOUNT)TOTAL_SALES FROM T ORDER BY 1 ASC
the desired output.
CHARGE_ID | TOTAL_GST | TOTAL_SALES |
51343382 | 4.7 | 41.7 |
51343383 | 279.37 | 2793.7 |
51343384 | -250 | -2500 |
51343384 | 279.37 | 2793.7 |
51343385 | 69.8 | 698 |
51446663 | -69.8 | -697.9 |
Hello
SELECT charge_id
, SUM (DECODE (type, 'GST', amount, 0)) AS total_gst
, SUM (DECODE (type, 'GST', 0, amount)) AS total_sales
T
GROUP BY charge_id
SIGN (amount)
ORDER BY charge_id
;
Oh, I see what you want! You want a separate line of production, for each distinct charge_id and for all the distinct combinations of charge_id and amount (positive and negative) sign. Just add another line for the GROUP BY (and, if you wish, ORDER BY) clause:
SELECT charge_id
, SUM (DECODE (type, 'GST', amount, 0)) AS total_gst
, SUM (DECODE (type, 'GST', 0, amount)) AS total_sales
T
GROUP BY charge_id
SIGN (amount)
ORDER BY charge_id
SIGN (amount)
;
This property returns exactly what you posted.
SIGN the declarations of (amount) + 1 if the amount is positive, and -1 if the amount is negative. If amount = 0, then it returns 0, and if the amount is NULL, returns the NULL value. Can you have amounts 0 or NULL in your data? If so, would what results you? You may need to use an expression BOX instead of (or in addition to) SIGN.
Tags: Database
Similar Questions
-
Since around seven 30 - Oct 1st or so I was unable to use all group functions in any group. 'Old' and those that I just created. I can't send or receive calls or messages in any group. I tried these steps below, and none of them worked. Help?
(1) sign out and back in
(2) change of profile information
(3) update the customer on the later (7.11.0.102)
(4) to uninstall and reinstall Skype
(5) clean uninstall and reinstall of Skype
(6) signature mobile to see if that will fix anything on the end of my PC
Mobile works very well, however my PC version does not. It worked very well in advance and then just suddenly stopped working for groups. Update the client did nothing. However, I can / message of appeal to people individually. I don't understand. I thought it was the linked server, but my friends have not had any problems...
Skype is based on some Windows Services work properly, or something?
I'm under 10 Home Windows (64-bit).
Welp, after scouring the net I found the problem. It turns out that my situation was the same as this post here.
-
Help with error - 934 group function is not allowed here
Hey there will, I'm having problems with a request and just does not know how to do it without error.
I'm trying to get all the employee emerging infectious diseases that have less than 2 number max of DID (dependants) in the table.
It's my current query
SELECT Employee.LName. ' ' || Employee.Fname as Full_Name, Employee.EID
The left outer JOIN employee depends on Employee.EID = Dependent.EID
Having Count (DID)--2 > ((select Max (N) as From (SELECT Employee.EID, Count (DID) As N FROM Employee Inner Join Dependent On Employee.EID = Dependent.EID group by Employee.EID, Count (DID))) N)
Order of Employee.Lname, Employee.Fname
Which gives me an error on column 4, no matter what I do. If I remove the Count (DID) in the group by clause (which I tried it earlier), it gives me a is not an error of the function of single group...
The most frustrating thing is that
Select Max (N) as From (SELECT Employee.EID, Count (DID) As N FROM Employee Inner Join Dependent On Employee.EID = Dependent.EID group by Employee.EID) N
Works perfectly, but because it's a mission, I have to do in one step (no substeps/views)
Any help?
Thank you very much
Hello
ac981e5d-D10A-4520-BF42-23a894d04fb7 wrote:
Ok. I'm taking your code in a view... I get this.
and there is an orange underscore and a text of the error that says
Select incoherent list in group by... change the group by clause of e.fname, e.lname, e.eid, count, max
Which isn't what either the Oracle database would do. Everything about orange (or any other color) sounds like it is caused by a front-end that could be interacting with Oracle. In addition, the Oracle error messages always come with a 3-letter-5 code, as ORA-00933.
under the selection internal (first medium)
You have deleted the WITH clause. The parser can recognize the error when it has reached the first left parenthesis.
Create view AS A10T2
(
SELECT e.lname. ' ' || e.fname AS full_name
e.eid
(D.) AS this_group_count
MAX (COUNT (d.)) ON (AS highest_group_count)
E employee
LEFT OUTER JOIN dependent d ON e.eid = d.eid
GROUP BY e.lname, e.fname, e.eid
)
SELECT full_name
eid
Of aggregate_results
WHERE this_group_count > = highest_group_count - 2
ORDER BY full_name
You need the WITH to define this clause means "AGGREGATE_RESULTS":
Create view AS A10T2
WITH aggregate_results AS
(
SELECT e.lname. ' ' || e.fname AS full_name
...
Why do you have an ORDER BY clause in a view? (It is probably not cause of your errors, just make the inefficient view)
Command line error: column 5: 23
Error report-
SQL error: ORA-00933: SQL not correctly completed command
00933 00000 - "not correctly completed SQL command.
* Cause:
* Action:
This is another indication that some front is getting involved. Looks like your front-end reports the exact Oracle error message, "0RA-00933" and then builing it's own error code, "00933. 00000 ", on this basis. ORA-00933 is a reasonable mistake to wait if you omit the line ' WITH the aggregated results AS. Once again, until I can actually run your code, I can't test it, and I can't run your code until you post CREATE TABLE and INSERT statements for some examples of data, or change the problem to use commonly available tables, such as those in the scott schema.
and when I try my code
CREATE VIEW A10T2 AS
SELECT Employee.LName. ' ' || Employee.Fname as Full_Name, Employee.EID
The left outer JOIN employee depends on Employee.EID = Dependent.EID
Seen (Count (DID)) + 2 > (select Max (N) From (SELECT Employee.EID, Count (DID) As "N" FROM Employee Inner Join Dependent On Employee.EID = Dependent.EID group by Employee.EID))
Order of Employee.Lname, Employee.Fname
I get
Command line error: column 2: 8
Error report-
SQL error: ORA-00937: not a function of simple-group
00937 00000 - 'not a single-group function.
* Cause:
* Action:
Then the orange underscore even under my inner ("select employee. EID, Count (DID) as "N" ") says to change the Group of Employee.eid, Count (DID)
I just don't understand why he tells me to group them by Count (DID)?
Isn't that what you did in your original post, and I have explained in answer #2? If you continue to repeat the same mistake, you can expect continue to get the same error. Given that you have a code, you know causes an error, do you think really that what makes a vision will cause the error to disappear?
The inner query works fine on its own...
Right; It's the outer query where you are missing the GROUP BY clause.
-
After you download the security update 2015-008 I lost the function of the function keys and some other functions. Have already played with the keyboard f nothing helps. Are also past system on and outside... need help pls
PS noticed the update downloaded twice
disregard my previous question... I found the answer: F1, F2 has been ticked on.
-
Some of function boxes are elongated and may not reach the OK box
original title: Windows Vista - Control Panel customization to enlarge the font size. Some of function boxes are elongated and may not reach the OK box
Using Windows Vista. I used the customization Panel control to enlarge the font size. I discovered that some boxes, like Adobe Reader Print and function, in effect, the Personaization (to reduce the font size to original size) require a click OK. But the box frame with large font size, is elongated until I can't get the OK. How to get to the OK or reduce the size of the police without the OK?
Simply press enter instead of OK.
-
ISE is associated with the AD, but some groups are missing
People,
In my ISE I already joined my announcement on a Windows 2008 Server. But when I retrieve groups with *, some groups are missing. I mean there is a band like XXX.COM\COMPANY\IDG\HR in my 2008 Server, but I can't get back in my ISE, the group is Global. Is this a bug of ISE or are there special limits in import of my groups in ISE?
Kind regards
ISE can retrieve the list of groups max 100 and as you have said that the number did not reach 100, check if the configuration of Active Directory in the user node Administration ISE
the interface is correct or you can add that the lack of groups directly use that check the following to add groups manuallyhttp://www.Cisco.com/en/us/docs/security/ISE/1.0/user_guide/ise10_man_id_stores.html#wp1059262
-
Not a "simple-group function.
SQL > select max(THREAD#), SEQUENCE #, NAME from v$ archived_log;
Select max(THREAD#), SEQUENCE #, NAME from v$ archived_log
*
ERROR on line 1:
ORA-00937: not a single group group function
Often, I face "not a single-group function. I tried with the order by clause, also,
-Please clarify why this error occurs?
Hello
You must use Group by clause in your query when you use the Group feature as count, sum, max in query
Select max(THREAD#), SEQUENCE #, NAME of Group v$ archived_log by SEQUENCE #, NAME;
Thank you
Su.GI
-
Hello
I have this request with meselect mst.ENTRY_DATE ordered_date , mst.FIELD, V.ADDRESS1 Address , OPN_JOB_DESC job_number, ra.CUSTOMER_NAME customer_NAME, DECODE ( GROSS_ITEM_REF , NULL , SUBSTR (PRODUCT_ATTR_VAL_DISP , INSTR( PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ) , GROSS_ITEM_REF ) item_number, dECODE (GROSS_ITEM_NAME , NULL,itm.attribute2,GROSS_ITEM_NAME ) item_description, subdtlest.ITEM_UOM unit_of_measurement, SUM ( subdtlest.QTY_ISSUE ) Quantity_Issue, sum(nvl (subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT ) ) quantity , mst.DN_DESCRIPTION Description --decode(MST.DESCRIPTION ,NULL ,mst.DN_DESCRIPTION,MST.DESCRIPTION) Description from XXNP_OPN_JOBLOG_001 mst , XXNP_OPN_JOBLOG_STAGE_002 dtl , XXNP_OPN_JOBLOG_SLURRY_003 subdtl , XXNP_OPN_JOBLOG_EST_002 subdtlest, qp_list_lines_v line , QP_LIST_HEADERS_TL head , QP_LIST_HEADERS_B curr, ra_customers ra , AR_ADDRESSES_V v , MTL_SYSTEM_ITEMS itm where dtl.OPN_JOBLOG_001_ID = mst.OPN_JOBLOG_001_ID AND subdtl.OPN_JOBLOG_001_ID = dtl.OPN_JOBLOG_001_ID AND subdtl.OPN_JOBLOG_006_ID = dtl.OPN_JOBLOG_006_ID and subdtlest.OPN_JOBLOG_001_ID = subdtl.OPN_JOBLOG_001_ID AND subdtlest.OPN_JOBLOG_006_ID = subdtl.OPN_JOBLOG_006_ID AND subdtlest.OPN_JOBLOG_007_ID = subdtl.OPN_JOBLOG_007_ID AND line.LIST_HEADER_ID = head.LIST_HEADER_ID and curr.LIST_HEADER_ID = head.LIST_HEADER_ID and substr ( PRODUCT_ATTR_VAL_DISP , 1, instr ( PRODUCT_ATTR_VAL_DISP ,'.' )-1 ) = subdtlest.ITEM_NUMBER and itm.SEGMENT3 = substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ) and mst.CONTRACT = head.name and RA.CUSTOMER_ID = v.CUSTOMER_ID and ra.customer_id = mst.customer_id and V.ADDRESS1 = mst.CONTRACT and mst.OPN_JOB_DESC='K/D/UP24/UN006/KOP/PL/0112/1' and itm.ORGANIZATION_ID =103 and itm.INVENTORY_ITEM_STATUS_CODE = 'Active' group by mst.ENTRY_DATE , V.ADDRESS1 , OPN_JOB_DESC ,mst.FIELD, ra.CUSTOMER_NAME , substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ), itm.ATTRIBUTE2 , subdtlest.ITEM_UOM , mst.DN_DESCRIPTION ,GROSS_ITEM_REF ,GROSS_ITEM_NAME order by substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ) Asc i require a field called balance which is sum of Quantity_issue and Quantity fields
thanking in advancei tried this select mst.ENTRY_DATE ordered_date , mst.FIELD, V.ADDRESS1 Address , OPN_JOB_DESC job_number, ra.CUSTOMER_NAME customer_NAME, DECODE ( GROSS_ITEM_REF , NULL , SUBSTR (PRODUCT_ATTR_VAL_DISP , INSTR( PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ) , GROSS_ITEM_REF ) item_number, dECODE (GROSS_ITEM_NAME , NULL,itm.attribute2,GROSS_ITEM_NAME ) item_description, subdtlest.ITEM_UOM unit_of_measurement, SUM ( subdtlest.QTY_ISSUE ) Quantity_Issue, sum(nvl (subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT ) ) quantity , sum(sum(nvl (subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT ) ) + SUM ( subdtlest.QTY_ISSUE ) )balance, mst.DN_DESCRIPTION Description --decode(MST.DESCRIPTION ,NULL ,mst.DN_DESCRIPTION,MST.DESCRIPTION) Description from XXNP_OPN_JOBLOG_001 mst , XXNP_OPN_JOBLOG_STAGE_002 dtl , XXNP_OPN_JOBLOG_SLURRY_003 subdtl , XXNP_OPN_JOBLOG_EST_002 subdtlest, qp_list_lines_v line , QP_LIST_HEADERS_TL head , QP_LIST_HEADERS_B curr, ra_customers ra , AR_ADDRESSES_V v , MTL_SYSTEM_ITEMS itm where dtl.OPN_JOBLOG_001_ID = mst.OPN_JOBLOG_001_ID AND subdtl.OPN_JOBLOG_001_ID = dtl.OPN_JOBLOG_001_ID AND subdtl.OPN_JOBLOG_006_ID = dtl.OPN_JOBLOG_006_ID and subdtlest.OPN_JOBLOG_001_ID = subdtl.OPN_JOBLOG_001_ID AND subdtlest.OPN_JOBLOG_006_ID = subdtl.OPN_JOBLOG_006_ID AND subdtlest.OPN_JOBLOG_007_ID = subdtl.OPN_JOBLOG_007_ID AND line.LIST_HEADER_ID = head.LIST_HEADER_ID and curr.LIST_HEADER_ID = head.LIST_HEADER_ID and substr ( PRODUCT_ATTR_VAL_DISP , 1, instr ( PRODUCT_ATTR_VAL_DISP ,'.' )-1 ) = subdtlest.ITEM_NUMBER and itm.SEGMENT3 = substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ) and mst.CONTRACT = head.name and RA.CUSTOMER_ID = v.CUSTOMER_ID and ra.customer_id = mst.customer_id and V.ADDRESS1 = mst.CONTRACT --and OPN_JOB_DESC = :P_JOB_NUMBER and itm.ORGANIZATION_ID =103 and itm.INVENTORY_ITEM_STATUS_CODE = 'Active' and mst.OPN_JOB_DESC='K/D/UP24/UN006/KOP/PL/0112/1' group by mst.ENTRY_DATE , V.ADDRESS1 , OPN_JOB_DESC ,mst.FIELD, ra.CUSTOMER_NAME , substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ), itm.ATTRIBUTE2 , subdtlest.ITEM_UOM , subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT, subdtlest.QTY_ISSUE , mst.DN_DESCRIPTION ,GROSS_ITEM_REF ,GROSS_ITEM_NAME order by substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1 ) Asc but i get the cursor pointing to mst.entry_date and the message "not a single group function" kindly guide me
-
Hello
Is it possible to aggregate group functions based on a field in responses, my query is below:
SELECT Absence_Days,
Absence_Reason,
Absence_Type,
Employee_name,
End_date,
First name,
Last_name,
Person_Id,
Start_date,
DEPARTMENT,
DIVISION,
INTERNAL_LOCATION,
CASE
WHERE LAST_NAME = 'Gordon '.
THEN COUNT (person_id) * COUNT (Person_Id) * SUM (Absence_Days)
0 OTHERWISE
END
FROM EMP
WHERE LAST_NAME = 'Gordon '.
GROUP OF ABSENCE_DAYS, ABSENCE_REASON, ABSENCE_TYPE, EMPLOYEE_NAME, END_DATE, FIRST_NAME, LAST_NAME, PERSON_ID, START_DATE, DEPARTMENT, DIVISION, INTERNAL_LOCATION
Count (person_id) * COUNT (Person_Id) * SUM (Absence_Days) returns a value by each line and aggregate in the column of fx. I want to this group by person_id, is this possible?
Thank youHello
Try this in Fx
SUM (Absence_Days by person_id)
Thank you
Saichand.v -
The local users and 'Add Member to group' groups function displays the password in clear text
Hello
I saw something strange that happens when you add the connected locally to the domain user to a local security group via lusrmgr.msc. This seems to be repeated in our Organization, and I was wondering if it's something to do with our generation, or if it is more widespread? After you have selected the locally connected user (domain) to be added to a local security group, but before confirming with OK / apply, the user name appears in the ACL in the format:
Domain\username (password@fulldomain)
The password appears when the user name should be, which is probably just a minor bug where an incorrect value is selected on the screen, but the fact that it is displayed in plain text rather than a hash of password is a little more disconcerting. There seems to be some caveats: it affects only the users in the domain (local users are displayed differently); It is not affected by the local administrator rights (although /are/ to add the user to the local administrator rights); It doesn't affect that the user logged on locally (I can't reproduce as a runas user).
The steps to reproduce this are:
(1) start | Run | lusrmgr.msc
(2) go to the groups. [Any group] | Right-click | Add to group
3) click on add
(4) enter the username of the user locally. OkAnyone else see this behavior?
See you soon,.
Dines keV
Hello
The question you posted would be better suited to the TechNet community. Please visit the link below to find a community that will provide the support you want.
http://social.technet.Microsoft.com/forums/en-us/category/w7itpro
Hope this information is useful.
-
Analytical and group functions of
Oracle 11g Release 2 Server
SQL, SQLPLUS not
I need to 'break' when a column value changes and insert a line with only a dash.
CREATE TABLE tab ( id number , part_num number , part_type_id number , part_type_txt varchar2(50) , CONSTRAINT tab_pk PRIMARY KEY(part_num,part_type_id) ) / insert into tab values(1,10,100,'hose') ; insert into tab values(1,10,110,'hose clamp') ; insert into tab values(1,20,200,'plastic value') ; insert into tab values(1,20,210,'brass value') ; insert into tab values(1,30,300,'headlamp') ; insert into tab values(1,30,310,'lamp misc') ; commit ; select part_num,part_type_id,part_type_txt, count(part_num) CNT from tab where id = 1 group by part_num,part_type_id,part_type_txt order by part_num,part_type_id ; PART_NUM PART_TYPE_ID PART_TYPE_TXT CNT ---------- ------------ ------------------- ---------- 10 100 hose 1 10 110 hose clamp 1 20 200 plastic value 1 20 210 brass value 1 30 300 headlamp 1 30 310 lamp misc 1
My query:
WITH data AS ( select case when nvl( lag( part_num ) over( order by rownum ), ' ' ) != part_num then part_num end part_num , part_type_id, part_type_txt, count(part_num) CNT from tab where id = 1 group by case when nvl( lag( part_num ) over( order by rownum ), ' ' ) != part_num then part_num end , part_type_id , part_type_txt order by part_num,part_type_id ) SELECT rownum, d.part_num,d.part_type_id, d.part_type_txt FROM data d ; ERROR at line 11: ORA-30483: window functions are not allowed here
I guess that analytical functions are not allowed in a group by clause.
Output desired, he had to 'break' on when PART_NUM changes and insertion of a line with a dash (-):
PART_NUM PART_TYPE_ID PART_TYPE_TXT CNT ---------- ------------ ------------------- ---------- 10 100 hose 1 10 110 hose clamp 1 - 20 200 plastic value 1 20 210 brass value 1 - 30 300 headlamp 1 30 310 lamp misc 1
Any help appreciated.
Hello
I see: XYZ123 is linked only to a part_type_id, 7777, so you do not want any output to XYZ123.
Similarly, XYZ456 is only linked to a part_type_id, 8888, so you do not want XYZ456.
One thing you can do is to start with the query in response to #4 above. The results of this query, you can count part_type_ids h: different lots, each part_num is bound to and then only display the part_nums who have more than 1 part_type_id. For example:
WITH got_aggregates AS
(
SELECT THE CHECK BOX
WHEN you GROUP (part_type_id) = 0
THEN TO_CHAR (part_num)
ELSE '-'
END AS txt
part_type_id, part_type_txt
CASE
WHEN you GROUP (part_type_id) = 0
THEN COUNT (part_num)
END AS cnt
part_num,
COUNT (DISTINCT part_type_id)
COURSES (PARTITION BY part_num) AS part_type_id_cnt
TAB
ID WHERE = 1
GROUP BY part_num, ROLLUP (part_type_id, part_type_txt))
)
SELECT txt, part_type_id, part_type_txt, cnt
OF got_aggregates
WHERE part_type_id_cnt > 1
ORDER BY part_num, part_type_id
;
Note that the subquery got_aggregates is almost identical to the response query #4. The only differences are that the subquery is not an ORDERBY clause (ORDER BY is almost always useless to subqueries) and includes two additional columns, which will be needed in the WHERE and ORDER BY the main query clauses.
-
Just trying to figure my best options, looks like your hook with Adobe.
There are actually two routes from Adobe, you can take. One of them is to subscribe to the creative cloud and pay a monthly subscription of $9.99. For this tax, you get the latest Photoshop and the latest Lightroom and all improvements that come along. It is true that if you decide that you do not want to continue your subscription, you will lose functionality in the programs. The other method is to acquire directly from Adobe Lightroom. It can be purchased from this site:
You can buy right now the 5 Lightroom and download it. If there are several updates Lightroom 5, you will get free updates. You will be able to use Lightroom 5 "forever". You have the license to use 5 Lightroom, and it does not expire. Don't forget that when Lightroom 6 is out you will have more no support from Adobe, nor will there be additional updates at your disposal. It's a bit like buying a used car. You can use it for as long as it works for you, but there is no support from society.
The choice is yours, of course. Personally, I think that plan creative cloud works really well. It is economical, and he assures you that you will always have the latest versions of Photoshop and Lightroom. But if this plan doesn't appeal to you, then you can buy 5 Lightroom from the link I provided above. 5 Lightroom is an excellent program. But he reaches the end of its life cycle. You can now buy it and install updates that may come. And it is possible that there will be another update or two who might support some new cameras. But when Lightroom 6 came out, if you want the new features and support for new cameras, then you will need to purchase a version update of Lightroom 6. One that suits you best, it is something only you can decide.
-
Function group can be nested?
Hello
MU peleipua wrote:
Function group can be nested?One of the aggregate functions can be nested inside of each other. The GROUP BY clause will be aplly to domestic.
For example:SELECT AVG (SUM (sal)) AS avg_dept_sal FROM scott.emp GROUP BY deptno ;
First of all, the SUM is calculated for each Department, then the average of these numbers is taken.
The result set of a query with a nested aggregate functions always contains 1 row.AVG_DEPT_SAL ------------ 9675
To understand what is happening, you may find it useful to run a similar query without the external function:
SELECT deptno , SUM (sal) AS dept_sal FROM scott.emp GROUP BY deptno ;
Output:
. DEPTNO DEPT_SAL ---------- ---------- 30 9400 20 10875 10 8750
You cannot nest deeper than that of aggregation functions.
-
Need help with Group functions
I'm a total novice with SQL, so please forgive me if the answer to my question seems to be too obvious
I work with diagrams of the sample (in particular with the employees table):
DESC employees;
result
What I have to do is select all the managers, including the number of subordinates is higher than the average number of subordinates of managers who work in the same Department. What I've done so far is as follows:
SELECT mgr.employee_id manager_id, Director of mgr.last_name, mgr.department_id, COUNT (emp.employee_id)
Employees emp employees JOIN Bishop
ON emp.manager_id = mgr.employee_id
GROUP OF mgr.employee_id, mgr.last_name, mgr.department_id
ORDER BY mgr.department_id;
result
As you can see, I'm almost done. Now, I need only to calculate the average of the result of the COUNT function for each Department. But I'm totally stuck at this point.
All advice?Hello
Welcome to the forum!
user12107811 wrote:
I'm a total novice with SQL, so please forgive me if the answer to my question seems to be too obviousJust the opposite! Looks like a very difficult mission.
I work with diagrams of the sample (in particular with the employees table):
DESC employees;
resultWhat I have to do is select all the managers, including the number of subordinates is higher than the average number of subordinates of managers who work in the same Department. What I've done so far is as follows:
SELECT mgr.employee_id manager_id, Director of mgr.last_name, mgr.department_id, COUNT (emp.employee_id)
Employees emp employees JOIN Bishop
ON emp.manager_id = mgr.employee_id
GROUP OF mgr.employee_id, mgr.last_name, mgr.department_id
ORDER BY mgr.department_id;
resultAs you can see, I'm almost done. Now, I need only to calculate the average of the result of the COUNT function for each Department. But I'm totally stuck at this point.
All advice?Yes, you're almost done. You just need to add one more condition. You have to calculate the average value of total_cnt (the COUNT (*) you already do) of a Department and compare that to total_cnt.
There are several ways to do this, including
a scalar subquery (in a HAVING clause)
(b) make a result set with one line per Department, containing the average_cnt and reach than your current result set
(c) analytical functions. Analytical functions are calculated after the GROUP BY clause is applied and aggregate functions are calculated, it is legitimate to say "AVG (COUNT (*)) MORE (...)").If thinking (c) is the simplest. It involves the use of a query of Tahina, but (a) and (b) also require subqueries.
This sounds like homework, so I'll do it for you.
Instead, here is a very similar problem with the hr.employees table.
Let's say that we are interested in total wages given each type of work in each Department.SELECT department_id , job_id , SUM (salary) AS sum_sal FROM hr.employees GROUP BY department_id , job_id ORDER BY department_id , job_id ;
Results:
DEPARTMENT_ID JOB_ID SUM_SAL ------------- ---------- ---------- 10 AD_ASST 4400 20 MK_MAN 13000 20 MK_REP 6000 30 PU_CLERK 13900 30 PU_MAN 11000 40 HR_REP 6500 50 SH_CLERK 64300 50 ST_CLERK 55700 50 ST_MAN 36400 60 IT_PROG 28800 70 PR_REP 10000 80 SA_MAN 61000 80 SA_REP 243500 90 AD_PRES 24000 90 AD_VP 34000 100 FI_ACCOUNT 39600 100 FI_MGR 12000 110 AC_ACCOUNT 8300 110 AC_MGR 12000 SA_REP 7000
Now suppose we want to find out which of these sum_sals is higher than the average sum_sal of his Department.
For example, in detriment 110 (near the end OIF the list) there two types of work (AC_ACCOUND and AC_MGR) that have sum_sals of 8300 and 12000. The average of these two numbers is 10150, so we selected AC_MGR (because its sum_sal, 12000, is superior to 10150, and we do not want to include AC_ACCOUNT, because its sum_sal, 8300, is less than or equal to the average of the Department.
In departments where there is only one job type (for example, Department 70, or null "Department" at the end of the list above) the only sum_sal will be the average; and because the sum_sal is not greater than the average, we want to exclude this line.Let's start with the calculation of the avg_sum_sal using the analytical function AVG:
SELECT department_id , job_id , SUM (salary) AS sum_sal , AVG (SUM (salary)) OVER (PARTITION BY department_id) AS avg_sum_sal FROM hr.employees GROUP BY department_id , job_id ORDER BY department_id , job_id ;
Output:
DEPARTMENT_ID JOB_ID SUM_SAL AVG_SUM_SAL ------------- ---------- ---------- ----------- 10 AD_ASST 4400 4400 20 MK_MAN 13000 9500 20 MK_REP 6000 9500 30 PU_CLERK 13900 12450 30 PU_MAN 11000 12450 40 HR_REP 6500 6500 50 SH_CLERK 64300 52133.3333 50 ST_CLERK 55700 52133.3333 50 ST_MAN 36400 52133.3333 60 IT_PROG 28800 28800 70 PR_REP 10000 10000 80 SA_MAN 61000 152250 80 SA_REP 243500 152250 90 AD_PRES 24000 29000 90 AD_VP 34000 29000 100 FI_ACCOUNT 39600 25800 100 FI_MGR 12000 25800 110 AC_ACCOUNT 8300 10150 110 AC_MGR 12000 10150 SA_REP 7000 7000
Now all we have to do is to compare the sum_sal and avg_sum_sal columns.
Given that the analytic functions are calculated after the WHERE clause is applied, we cannot use avg_sum_sal in the WHERE clause of the query, even where it has been calculated. But we can do that in a subquery; Then, we can use avg_sum_sal in any way that we love in the Super-requete:WITH got_avg_sum_sal AS ( SELECT department_id , job_id , SUM (salary) AS sum_sal , AVG (SUM (salary)) OVER (PARTITION BY department_id) AS avg_sum_sal FROM hr.employees GROUP BY department_id , job_id ) SELECT department_id , job_id , sum_sal FROM got_avg_sum_sal WHERE sum_sal > avg_sum_sal ORDER BY department_id , job_id ;
Results:
DEPARTMENT_ID JOB_ID SUM_SAL ------------- ---------- ---------- 20 MK_MAN 13000 30 PU_CLERK 13900 50 SH_CLERK 64300 50 ST_CLERK 55700 80 SA_REP 243500 90 AD_VP 34000 100 FI_ACCOUNT 39600 110 AC_MGR 12000
-
I followed some groups and contributors
But did not get any updates by email all weekend.
Change something?
Thank you!
Holly
Make sure that you always follow these groups and that it contributes. Over the years, I found that from time to time the forum destroyed my following, and I need to re - follow the things that I'm interested.
I don't know if that's a problem, or if there is a way to ensure that the user is always really interested in getting these emails, and if they aren't, it will reduce the number of servers forum need to send emails. TOTAL speculation on my part, but it happened to me several times since 2005 when I began to participate in the forums.
Maybe you are looking for
-
Favourite Add - ons disappear between sessions
When I start my computer lately, about three of my favorite FF (ver. 33.1.1) modules are installed is no longer. It's Lazarus, X-notify and theme and size Changer.I fonts can reinstall them manually, but it becomes a pain to do. I find that when I re
-
delays when writing with the pec in Portege M200
I face a very obvious slow in exercising the hand writing in tablet mode.usually, I write "with a single note" and writing is instantly displayed in normal writing on paper.but when I tilt the screen to be in tablet mode, what I write is not displaye
-
Cannot simulate devices in MAX
Hi all By train to try to simulate the card PCI-6503 using MAX and when I expand the tree 'Devices and Interfaces', I don't see any options to create any simulated device. I installed the software is: (1) DAQmx 9.9 (2) MAX 5.6 (3) Labview 2012 Evalua
-
Compaq 6730 s: upgrade HP compaq 6730 s RAM (4 GB - >; 8 GB)
Hello I have a 7 years hp compaq 6730 s running windows and ubuntu. It has 4 GB of ddr2 ram (667 MHz, according to me, but I'm not course on this) and a dual processor Intel Centrino 64-bit. It still works great. But I have to run long analysis and m
-
My image_ (D) factory has only 1.24 GB free of 9.16 GB
How can I remove unnecessary omse programs in order to free up space? The 1st week of November, I did a restore but has lost a lot of things that I thought were on my backup dvd