Help for identifing top sql statements
Hi all,
We are doing load testing on oracle 9i with 500 concurent users. At some point of
time the database was hang. I would like to know which query is taking more time/
which resource occuping more. Can any body help in this regard.
Thanks in advance
Some useful information can be found in V$SQLAREA, for example :
SQL> select SQL_TEXT, EXECUTIONS, DISK_READS, BUFFER_GETS, ROWS_PROCESSED, CPU_TIME, ELAPSED_TIME
2 from v$sqlarea
3* order by CPU_TIME desc;
Similar Messages
-
ADDM Findings Top SQL Statements
Hi,
I have run addmrpt.sql for 1 month of time using snapshots and every ADDM report says that sql statement having id **** listed under top sql statements findings and recommendation is to tune using sql tunning advisor. It has 2-4 seconds elapsed time.But when i go through AWR report instance efficiency report and all are normal.
Can anyone please confirm whether I should recommend to tune this SQL statement to my vendor ?
Thanks,
TKbelow is the sql I found in ADDM. As I understood it is an intername SQL not an application SQL. When i searched it in internet found that it is related with check_oracle_health plugin. can you please help me to understand this nagios concept and the relationship it has with oracle software. And also how should I identify which methods we are using to monitor database internally?
SELECT
a.tablespace_name "Tablespace",
b.status "Status",
b.contents "Type",
b.extent_management "Extent Mgmt",
a.bytes bytes,
a.maxbytes bytes_max,
c.bytes_free + NVL(d.bytes_expired,0) bytes_free
FROM
-- belegter und maximal verfuegbarer platz pro datafile
-- nach tablespacenamen zusammengefasst
-- => bytes
-- => maxbytes
SELECT
a.tablespace_name,
SUM(a.bytes) bytes,
SUM(DECODE(a.autoextensible, 'YES', a.maxbytes, 'NO', a.bytes))
maxbytes
FROM
dba_data_files a
GROUP BY
tablespace_name
) a,
sys.dba_tablespaces b,
-- freier platz pro tablespace
-- => bytes_free
SELECT
a.tablespace_name,
SUM(a.bytes) bytes_free
FROM
dba_free_space a
GROUP BY
tablespace_name
) c,
-- freier platz durch expired extents
-- speziell fuer undo tablespaces
-- => bytes_expired
SELECT
a.tablespace_name,
SUM(a.bytes) bytes_expired
FROM
dba_undo_extents a
WHERE
status = 'EXPIRED'
GROUP BY
tablespace_name
) d
WHERE
a.tablespace_name = c.tablespace_name
AND a.tablespace_name = b.tablespace_name@@@@@@@@
AND a.tablespace_name = d.tablespace_name
UNION ALL
SELECT
d.tablespace_name "Tablespace",
b.status "Status",
b.contents "Type",
b.extent_management "Extent Mgmt",
sum(a.bytes_free + a.bytes_used) bytes, -- allocated
SUM(DECODE(d.autoextensible, 'YES', d.maxbytes, 'NO', d.bytes))
bytes_max,
SUM(a.bytes_free + a.bytes_used - NVL(c.bytes_used, 0)) bytes_free
FROM
sys.v_$TEMP_SPACE_HEADER a,
sys.dba_tablespaces b,
sys.v_$Temp_extent_pool c,
dba_temp_files d
WHERE
c.file_id(+) = a.file_id
and c.tablespace_name(+) = a.tablespace_name
and d.file_id = a.file_id
and d.tablespace_name = a.tablespace_name
and b.tablespace_name = a.tablespace_name
GROUP BY
b.status,
b.contents,
b.extent_management,
d.tablespace_name
ORDER BY
1 -
Multiple Executions Plans for the same SQL statement
Dear experts,
awrsqrpt.sql is showing multiple executions plans for a single SQL statement. How is it possible that one SQL statement will have multiple Executions Plans within the same AWR report.
Below is the awrsqrpt's output for your reference.
WORKLOAD REPOSITORY SQL Report
Snapshot Period Summary
DB Name DB Id Instance Inst Num Release RAC Host
TESTDB 2157605839 TESTDB1 1 10.2.0.3.0 YES testhost1
Snap Id Snap Time Sessions Curs/Sess
Begin Snap: 32541 11-Oct-08 21:00:13 248 141.1
End Snap: 32542 11-Oct-08 21:15:06 245 143.4
Elapsed: 14.88 (mins)
DB Time: 12.18 (mins)
SQL Summary DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
Elapsed
SQL Id Time (ms)
51szt7b736bmg 25,131
Module: SQL*Plus
UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL,0) + NVL(ACCT_DR_BAL,
0)) FROM ACCT WHERE ACCT_TRN_DT = (:B1 ) AND TEST_ACC_NB = ACCT_ACC_NB(+)) WHERE
TEST_BATCH_DT = (:B1 )
SQL ID: 51szt7b736bmg DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
-> 1st Capture and Last Capture Snap IDs
refer to Snapshot IDs witin the snapshot range
-> UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL,0) + NVL(AC...
Plan Hash Total Elapsed 1st Capture Last Capture
# Value Time(ms) Executions Snap ID Snap ID
1 2960830398 25,131 1 32542 32542
2 3834848140 0 0 32542 32542
Plan 1(PHV: 2960830398)
Plan Statistics DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
-> % Total DB Time is the Elapsed Time of the SQL statement divided
into the Total Database Time multiplied by 100
Stat Name Statement Per Execution % Snap
Elapsed Time (ms) 25,131 25,130.7 3.4
CPU Time (ms) 23,270 23,270.2 3.9
Executions 1 N/A N/A
Buffer Gets 2,626,166 2,626,166.0 14.6
Disk Reads 305 305.0 0.3
Parse Calls 1 1.0 0.0
Rows 371,735 371,735.0 N/A
User I/O Wait Time (ms) 564 N/A N/A
Cluster Wait Time (ms) 0 N/A N/A
Application Wait Time (ms) 0 N/A N/A
Concurrency Wait Time (ms) 0 N/A N/A
Invalidations 0 N/A N/A
Version Count 2 N/A N/A
Sharable Mem(KB) 26 N/A N/A
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | UPDATE STATEMENT | | | | 1110 (100)| |
| 1 | UPDATE | TEST | | | | |
| 2 | TABLE ACCESS FULL | TEST | 116K| 2740K| 1110 (2)| 00:00:14 |
| 3 | TABLE ACCESS BY INDEX ROWID| ACCT | 1 | 26 | 5 (0)| 00:00:01 |
| 4 | INDEX RANGE SCAN | ACCT_DT_ACC_IDX | 1 | | 4 (0)| 00:00:01 |
Plan 2(PHV: 3834848140)
Plan Statistics DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
-> % Total DB Time is the Elapsed Time of the SQL statement divided
into the Total Database Time multiplied by 100
Stat Name Statement Per Execution % Snap
Elapsed Time (ms) 0 N/A 0.0
CPU Time (ms) 0 N/A 0.0
Executions 0 N/A N/A
Buffer Gets 0 N/A 0.0
Disk Reads 0 N/A 0.0
Parse Calls 0 N/A 0.0
Rows 0 N/A N/A
User I/O Wait Time (ms) 0 N/A N/A
Cluster Wait Time (ms) 0 N/A N/A
Application Wait Time (ms) 0 N/A N/A
Concurrency Wait Time (ms) 0 N/A N/A
Invalidations 0 N/A N/A
Version Count 2 N/A N/A
Sharable Mem(KB) 26 N/A N/A
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | UPDATE STATEMENT | | | | 2 (100)| |
| 1 | UPDATE | TEST | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 28 | 2 (0)| 00:00:01 |
| 3 | INDEX RANGE SCAN | TEST_DT_IND | 1 | | 1 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| ACCT | 1 | 26 | 4 (0)| 00:00:01 |
| 5 | INDEX RANGE SCAN | INDX_ACCT_DT | 1 | | 3 (0)| 00:00:01 |
Full SQL Text
SQL ID SQL Text
51szt7b736bm UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL, 0) +
NVL(ACCT_DR_BAL, 0)) FROM ACCT WHERE ACCT_TRN_DT = (:B1 ) AND PB
RN_ACC_NB = ACCT_ACC_NB(+)) WHERE TEST_BATCH_DT = (:B1 )Your input is highly appreciated.
Thanks for taking your time in answering my question.
RegardsOracle Lover3 wrote:
Dear experts,
awrsqrpt.sql is showing multiple executions plans for a single SQL statement. How is it possible that one SQL statement will have multiple Executions Plans within the same AWR report.If you're using bind variables and you've histograms on your columns which can be created by default in 10g due to the "SIZE AUTO" default "method_opt" parameter of DBMS_STATS.GATHER__STATS it is quite normal that you get different execution plans for the same SQL statement. Depending on the values passed when the statement is hard parsed (this feature is called "bind variable peeking" and enabled by default since 9i) an execution plan is determined and re-used for all further executions of the same "shared" SQL statement.
If now your statement ages out of the shared pool or is invalidated due to some DDL or statistics gathering activity it will be re-parsed and again the values passed in that particular moment will determine the execution plan. If you have skewed data distribution and a histogram in place that reflects that skewness you might get different execution plans depending on the actual values used.
Since this "flip-flop" behaviour can sometimes be counter-productive if you're unlucky and the values used to hard parse the statement leading to a plan that is unsuitable for the majority of values used afterwards, 11g introduced the "adaptive" cursor sharing that attempts to detect such a situation and can automatically re-evaluate the execution plan of the statement.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Log for all the sql statement executed
Hi,
I would like to know how to see the log for all the sql statement executed starting from connection to all the database related actions.
Is it something that i need to set it up in the driver?
I'm using Tomcat and JDBC driver.
Please reply.
Thanks,
AnjanaMake your own.
Calendar cal = new GregorianCalendar();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
//use calendar object to get other infos such as time of query
//append your query string
File f =new File ("c:\\jakarta-tomcat-3.2.4\\webapps\\ASD\\LOGS\\log" + df.format(day) + df.format(month) + year + ".txt");
if (! f.exists())
f.createNewFile();
FileWriter fw = new FileWriter (f, true);
// append new log to end of file
fw.write(buf.toString());
fw.write("\n");
fw.flush();
fw.close();
catch (IOException ioe)
System.out.println(ioe.toString()); -
How to get the time for executing an SQL statement?
hi all...
How can I get the total execution time for a given SQL statement to a ViewObject which is created dynamically for this SQL so that the end user knows it before hand and try to stop it or go further..?
Please post any ideas if you have got..!!!
thanx in advance..
grüss
K°viThis is not really a question for the JDeveloper forum, but rather for the DB forum.
Since Oracle9i there is a way to estimate how long a query will take, before executing it.
Check it out in the Oracle DB documentation or ask on the DB forum.
There is no built-in functionality for this in JDeveloper, but you should be able to call out to the DB from your Java code to get the estimate. -
Can someone help me correct this sql statement in a jsp page?
ive been getting the java.sql.SQLException: Incorrect syntax error for one of my sql nested statements. i cant seem to find similar egs online, so reckon if anyone here could help, really appreciate it.
as im putting the nested sql in jsp page, it has to be with lots of " " n crap. very confusing if there are nested.
heres the sql statement without those "" that i want to use:
select top 5 * from(
select top+"'"+offset+"'"+" * from prod where cat=" +"'" cat "'"+"
)order by prodID desc
when i put this in my jsp pg, i had to add "" to become:
String sql = "select top 5 * from("+"select top"+"'"+offset+"'"+" * from prod where cat=" +"'" +cat+ "'"+")order by prodID desc";cat=" +"'" cat "'"+")order by prodID desc";
all those "" are confusing me to no end, so i cant figure out what should be the correct syntax. the error says the syntax error is near the offset.If offset is, say, 10, and cat is, say, "new", then it looks like you're going to produce the SQL:
select top 5 * from(
select top '10' * from prod where cat='new'
)order by prodID descThat looks exactly like incorrect syntax to me... top almost certainly can't handle a string literal as its operand... you almost certainly would want "top 10" instead of "top '10'"...
If you use PreparedStatement, you don't have to remember what you quote and what you don't and you can have your SQL in a single static final string to boot... -
Transaction or standard program for testing Open SQL statements
Hi experts,
Is there a standard program or transaction that can be used to test Open SQL statements?, I was thinking in something similar to a SQL client like sqlcli, but for Open SQL and within SAP GUI.
I know i can write a test ABAP program for this matter but I rather a standard testing facily in this case
Thank you for any help
regardsHi Ozcan
I tried DB02 -> Diagnosis -> SQL Command editor , but I couldn't made it work. It is for Open SQL or for Native SQL?
I tried the following simple Open SQL statements inside the SQL Code tab there were erros
SELECT *
FROM /BI0/PCOMP_CODE
error was: Incorrect syntax near '/'.
SELECT * FROM DD03L
error was: Invalid object name 'DD03L'.
Where is the mistake?
regards -
Please sugges the link helpful for writing efficient sql queries
Please suggest any good resource that is weblink which can help me in optimizing sql queries. especially while writing select statements improve the execution time of the sql query.
Thanx in advance
prasanthin general I found books from O'Reilly very helpful (not only for Oracle, but for Unix too).
Moreover there is pretty good Oracle Documentation available.
After all, it's not only about writing good queries, but also about setting up data-models, indexes, primary keys, etc.
Look for a real slow computer, take a lot of data, then try writing your speedy queries. This is the school of hard knocks, on the long run it's the best training. -
RFC for remote Open SQL statement
I'm looking for the SAP delivered RFC that will allow me to perform an SQL statement (select) onto another server.
I've used this before (years ago) but can't remember the FM name.
Please help!
Thanks,
AndreDid you try [RemoteOpenSQL|http://remoteopensql.codeplex.com/] ?
Filippo -
Procedure creation for 2 different sql statement
Hi all,
When I run a procedure with the below line:
cursor c1 is select object_name from user_objects where object_type='VIEW' and status='VALID';
procedure gets created successfully
But for the below line , oracle throws error
cursor c1 is select object_name from dba_objects where object_type='VIEW' and status='VALID';
Error Message:
Warning: Procedure created with compilation errors.
3/14 PL/SQL: SQL Statement ignored
3/38 PL/SQL: ORA-00942: table or view does not exist
Thanks for all your help.The below procedure gets created successfully:
CREATE OR REPLACE PROCEDURE P_TEST (schema_name in varchar2,new_usr in varchar2)
is
str varchar2(1000);
str_syn varchar2(1000);
v_obj_name varchar2(200);
begin
for z in ( select object_name from user_objects where object_type in ('VIEW') and status='VALID')
loop
v_obj_name:=schema_name||'.'|| z.object_name;
str :='grant select on '||v_obj_name||' to '|| new_usr ;
EXECUTE IMMEDIATE str;
end loop;
end;
where as below one throws error difference being "user_objects" replaced with
"dba_objects"
CREATE OR REPLACE PROCEDURE P_TEST (schema_name in varchar2,new_usr in varchar2)
is
str varchar2(1000);
str_syn varchar2(1000);
v_obj_name varchar2(200);
begin
for z in ( select object_name from dba_objects where object_type in ('VIEW') and status='VALID')
loop
v_obj_name:=schema_name||'.'|| z.object_name;
str :='grant select on '||v_obj_name||' to '|| new_usr ;
EXECUTE IMMEDIATE str;
end loop;
end; -
Look for histroy of sql statement executed in database
is there a way to look for histroy or list of sql statement executed in database.?
similar to history command in linux or bash shell.The newer <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2131.htm">v$sqlstats</a> (10g) is recommended over v$sql as (according to the documentation) it's "faster, more scalable, and has a greater data retention (the statistics may still appear in this view, even after the cursor has been aged out of the shared pool)", although it's missing a couple of the columns v$sql has.
The history version (if you are licenced for AWR, which is part of the extra-cost Diagnostics Pack - you may not be licenced to use it even if the dictionary views are installed) is DBA_HIST_SQLSTAT. -
Connecting strings for execution as SQL-Statement
Hello to all.
I've the problem, that I want to write a package which handels occuring erros as far as possible automatically.
One part is to recompile invalid objects.
I can find all these objects by useing the following cursor:
CURSOR curInvalidObjects
IS SELECT OBJECT_TYPE, OWNER, OBJECT_NAME
from dba_objects a
where STATUS = 'INVALID' and
OWNER = 'BESECKE' AND
OBJECT_TYPE in ( 'PACKAGE BODY',
'PACKAGE', 'FUNCTION', 'PROCEDURE',
'TRIGGER', 'VIEW' )
order by OWNER, OBJECT_TYPE, OBJECT_NAME;
After opening the cursor I can go trough the records and recompile the objects with something like this:
alter || recInvalidObjects.OBJECT_TYPE || ' '
|| recInvalidObjects.OWNER || '.' ||
recInvalidObjects.OBJECT_NAME || compile;
But that does not work. In this way I can't get any executable SQL-Statement. It just becomes a string, but it's not executable.
I think it's a simple problem, but I tried to find anything about executable stings in the documentation I have, and I could not find anything. So can anybody give me a short hint, how to create an executable statement?
Thanks a lot.
Susanne SaalmannIf you just recompile without taking the correct order of compilation into account, you will have to run your statement a couple of times. This script solves that:
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 9999
SET TIMING OFF
SET TERMOUT ON
COLUMN noprn NOPRINT
SPOOL comp.sql
SELECT 'ALTER '||
DECODE( o.object_type, 'PACKAGE BODY', 'PACKAGE', o.object_type)||
' '||decode(o.object_type,'JAVA CLASS','"',null)||
o.object_name || decode(o.object_type,'JAVA CLASS','"',null)||
' COMPILE '||
DECODE( o.object_type, 'PACKAGE BODY', 'BODY;', ';'),
COUNT( d.name ) noprn
FROM user_objects o,
user_dependencies d
WHERE o.object_name = d.referenced_name(+)
AND o.object_type = d.referenced_type(+)
AND o.status = 'INVALID'
GROUP BY o.object_name, o.object_type
ORDER BY noprn DESC
SPOOL OFF
SET HEADING ON
SET FEEDBACK ON
SET PAGES 14
START comp.sql
SHOW USER
SELECT object_type, status, count(*)
FROM user_objects
GROUP BY object_type, status -
Need Help in correcting the sql statement
H Experts,
I am not if I can post this query in this section, but as I am executing this statement on repository DB , I assumed to post here.
I have a requirement to calculate the database sizes from the tables in repository.
table 1 : MGMT$DB_TABLESPACES_ALL : has the information on all the tablespace information from each database. and it has information of all the databases.
table 2: MGMT$DB_REDOLOGS_ALL : has the information on all the redolog files information from each database. and it has information of all the databases.
Now to calculate the size of each database , we need to collect the sizes from both tables and then need to add.
below is the sql i prepared and sql didn't return and systax error , but the final output is completely wrong. Seems like its multiplying the data somewhere and getting the wrong information.
please help me in doing the required modifications.
=================================================================================================
select a.TARGET_NAME "DATABASE_NAME" ,sum(a.TABLESPACE_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE ALLOCATED SPACE(GB)",
sum(a.TABLESPACE_USED_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE USED SPACE(GB)",
sum(a.TABLESPACE_SIZE/1024/1024/1024)-sum(a.TABLESPACE_USED_SIZE/1024/1024/1024) "DATABASE FREE SPACE(GB)"
from MGMT$DB_TABLESPACES_ALL a ,MGMT$DB_REDOLOGS_ALL b
where a.TARGET_NAME=b.TARGET_NAME and a.TARGET_Name like '%d2oem%'
group by a.target_name;
====================================================================================================
Note: There are multiple records having the same TARGET_NAME value in both the tables.
please Help me in correcting the sql statementH Experts,
I am not if I can post this query in this section, but as I am executing this statement on repository DB , I assumed to post here.
I have a requirement to calculate the database sizes from the tables in repository.
table 1 : MGMT$DB_TABLESPACES_ALL : has the information on all the tablespace information from each database. and it has information of all the databases.
table 2: MGMT$DB_REDOLOGS_ALL : has the information on all the redolog files information from each database. and it has information of all the databases.
Now to calculate the size of each database , we need to collect the sizes from both tables and then need to add.
below is the sql i prepared and sql didn't return and systax error , but the final output is completely wrong. Seems like its multiplying the data somewhere and getting the wrong information.
please help me in doing the required modifications.
=================================================================================================
select a.TARGET_NAME "DATABASE_NAME" ,sum(a.TABLESPACE_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE ALLOCATED SPACE(GB)",
sum(a.TABLESPACE_USED_SIZE/1024/1024/1024)+sum(b.LOGSIZE/1024/1024/1024/1024) "DATABASE USED SPACE(GB)",
sum(a.TABLESPACE_SIZE/1024/1024/1024)-sum(a.TABLESPACE_USED_SIZE/1024/1024/1024) "DATABASE FREE SPACE(GB)"
from MGMT$DB_TABLESPACES_ALL a ,MGMT$DB_REDOLOGS_ALL b
where a.TARGET_NAME=b.TARGET_NAME and a.TARGET_Name like '%d2oem%'
group by a.target_name;
====================================================================================================
Note: There are multiple records having the same TARGET_NAME value in both the tables.
please Help me in correcting the sql statement -
I have looked through the video tutorials for CS6 and cant find any help for PHP using SQL.
Where is a good place that I can go to learn more about using dreamweaver and different languages than html. Is there a service that adobe offers that I could buy that would take me from rookie all the way to professional with a good easy to use structure such as adobe tv but more advanced and thorough? I am trying to build a website with a log in page and registration. I have the HTML part down well enough but need help writing the php scripts and using SQL to store the user info
I'm moving this to the main Dreamweaver support forum.
In answer to your question, you need to be aware that the PHP server behaviors in Dreamweaver CS6 use the original MySQL functions that are scheduled to be removed from a future version of PHP. The server behaviors have already been removed from Dreamweaver CC. If you are planning to create a site using PHP and MySQL, do not rely on Dreamweaver's server behaviors. You must use either MySQLi (MySQL Improved) or PDO (PHP Data Objects) instead.
If you're looking for video tutorials, you might be interested in the courses I have created for lynda.com. As a beginner, a good place to start would be PHP for Web Designers or Introducing PHP (there are several sample videos that you can watch for free on my website). Both courses were recorded on Dreamweaver (PHP for Web Designers on Dreamweaver CS6, Introducing PHP on Dreamweaver CS5.5). PHP for Web Designers shows how to connect to MySQL with MySQLi. You need a subscription to lynda.com to watch the complete courses, but you can get a seven-day free trial by following the links on my website.
If you don't want to commit to a subscription service, I have also written a book called PHP Solutions, which covers MySQLi and PDO in depth. It also shows how to build a login system. At the moment, the second edition is available, but a revised third edition is due to go on sale in December.
There are also a lot of free resources on the web that you can find. The important thing to beware of is that a lot of old material relies on the original MySQL functions. Whichever resource you use, make sure it shows how to use MySQLi or PDO. -
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 ;thankshi
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
Maybe you are looking for
-
Photoshop Elements 11 download Win 8.1
Hi I'm trying to instal a copy of Elements 11 onto my new laptop but am having trouble extracting the files PhotoshopElements_11_LS15 PhotoshopElements_11_WWEFDJ which I downloaded from Adobe. Is there somewhere else I can just download Elements 11,
-
ICloud erased all my calendar entries
Hello community. I should much appreciate help with the following. 1. I have (had) a lot of calendar entries in my iPhone 4S. 2. I thought I should start to share my calendar with my Retina. 3. I went to iPhone settings, iCloud, turned On the Calenda
-
Downloading ebook to Adobe Digital Editions produces activation error
Hi there, So I bought an ebook from the Google ebook store. I then wanted to change it to the Epub format, so I can read it on my Kobo Touch device. Using Digital Editions, I went to 'File', then 'Add to Library'. I went to 'Downloads' on my pc, and
-
AT&T announced today that they will start selling the iphone 3G contract free for $600-$700 depending on the model. You're still tied to AT&T as a carrier, and as of right now, the offer is limited to current AT&T customers. You also still have to si
-
Automatically start with numbers lock on
when i start up pc the numbers lock is always OFF, so, to enter my 4 digit pin i always need to push the numbers lock key, FIRST. can't this numbers lock key be enabled (on boot) automatically, so all i need type is my 4 digit pin? Can't seem to loca