SQL select statements
Hey everybody,
First of all, Yes, I searched through the 8.5 database schema guide. As I went through the scheme, I've developed some ideas on how to collect the data you want. However, if someone has already developed or found the SQL statements (which I'm sure that someone already has) it would help by reducing to the minimum of the buggs in my data collection program.
All these statistics must be grouped by CSQ and selected for a certain time interval (
1 total calls presented by the CSQ 2. total number of calls answered by the CSQ 3 total number of calls abandoned by the CSQ 4. percentage of calls abandoned by CSQ (if it is not stored in the database, I think:
5. average abandon time in seconds (if it is not stored in the DB, I think: sum (
6. service level - % calls answered in 90 seonds by a set of skills (I have seen metServiceLevel in the ContactQueueDetail table; however, I need to find how to configure this threshold for application) 7. average speed of response by CSQ 8 average conversation by CSQ calls 9. the aggregates connected full-time resources or agents CSQ 10. resources/agents of CSQ ready time I realize that some of them should be easy to find (as I always am search in the guide of db schema), but I was reading how a new record is created for each step of the call so I could easily see how I could get inaccurate information without properly developed select statements. Any help will be greatly appreciated. Brendan Brendan, I read your message very well. You have the schema of database with tables and description. each table has its associated tables (connected with primary and foreign keys). I think you should start the tables to determine what you need. Cisco uses the stored procedure to prepare the reports. the stored procedure is 'sp_csq_interval' to create the report. Activity report of Queue Service contact" HTH Anas Please note all useful posts Tags: Cisco Support What is the sql SELECT statement to list all service names in the database? Hello You can try this query: Hope this helps. SQL SELECT statement as a parameter in the procedure of string This can help. NULL in PL/SQL SELECT statement.. Hello Bartek With the help of inplace column number of the column name in the SQL Select statement You can extract the names of the columns for user_tab_columns Use dynamic SQL and then the result to get the values. But as others already mentioned, this wil it be given incorrect if your table is changed. A loop using the SQL select query. Like this? Handeling string in a select statement citing alternative: How to format the output of a .sql script that has select statements. Hello I have a .sql script which is having several select statements. Each Select statement is to have hundreds of Table columns. When we run the .sql script, we are unable to read the output. Please let know us the commands that we include for better readable output format. You work with the lin standard set 80. Is it possible to use the record type or a PL/SQL table in the Select statement 830960 wrote: In general, Yes, if the function is a function table, you can do something like: SY. How can I include multiple SELECT statements in a PL/SQL? Try this, Hope this helps, Skip and capture the Oracle SQL record dirty in a select statement Hello I have the Oracle Oracle 11.2.0.4 database when I run a select query. Question: 10 columns have given Date format. When I try to execute this query into a FROG he says, a month not valid. Since the records are billion in nature, I am not able to know which line has this problem. Is there a way I can capture the failed row and add it to other tables and continues with the select statement regardless of this error OK, you have several TO_DATE functions fed a string that is built on the fly. At least part of the time, the chain that is built does not match the date format mask used. For example: TO_DATE (SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID), 0, 8). » -'|| SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. (LAST_SUBMITTED_ON_DTTM_WID), 9, 6), "YYYYMMDD-HH24MISS") "SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' does not have a string where characters 5-6 are in the range 01-12. You'll have to do an analysis on this column. From its data and how that is managed by to_char. What ARE the data type of ' SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' and what is a typical value? As others have said, this is simply an impossibility for a column of a table to actually have invalid month (or day, or year, or hour or minute or second). ONLY, you get this error during the conversion of a string to a date with the TO_DATE function. Need help with the use of GROUP BY in a select statement UNION I am writing a query that allows to combine a legacy system that interfaces it is trial balance in the Oracle of R12 GL. It was only meant to continue for a month or two, but it is likely to continue for 6 months. Please Auditors Auditors, to provide proof that the system is in balance with Oracle GL. By my verification requirements, I need to make a full reconciliation from the month of conversion (life in the amount of date), then PTD for each month. The legacy account is placed in attribute1 on the lines of the journals. Uses of the old system balancing segments that are also used on the platform in Oracle for this division, i.e., Procure-to-Pay has been cut over Oracle, but not everything yet. So, I can't count on the GL_BALANCES table for the info, I get from the JE_LINES. My problem is not the only request for the month. But when I try to combine the queries with a Union, to aggregation of each measurement period in its own column, the group is necessary after each selected instruction rather than allowing me to put at the end of the UNION. (When I put the group by at the end of the UNION, I have the 'not one group' function) So I get duplicate for each month of discrete measure accounts. When I duplicate in my Oracle database accounts, I can't count on the VLOOKUP function in excel to exactly match an account of inheritance. I know there are more sophisticated ways to provide this output, but I'm hoping to get this info in a simple query. Thank you in advance for any advice you can provide Example of data output (the goal for me is to get the two rows to appear as one based on common points on the LEGACY_ACCOUNT and the ORACLE ACCOUNT Here is a simplified version of my code that returns both records. In my research, I had found a number of conversations where it has been shown that the group could be put at the end of the select statement. However, when I remove the group from the first select statement I get SQL error: ORA-00937: not a function of simple-group Select l.attribute1 LEGACY_ACCOUNT, C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8, JUN_15 TO_NUMBER('0'). JUL_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)), TO_NUMBER('0') AUG_15. TO_NUMBER('0') SEP_15. TO_NUMBER('0') OCT_15. TO_NUMBER('0') NOV_15. DEC_15 TO_NUMBER('0') Of b GL.gl_je_batches, GL.gl_je_headers h, GL.gl_je_lines l, GL.gl_code_combinations c, GL.gl_je_sources_tl j where b.je_batch_id = h.je_batch_id and h.je_header_id = l.je_header_id and l.code_combination_id = c.code_combination_id and h.je_source = j.je_source_name and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',) ('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337') and j.language = 'en '. and h.PERIOD_NAME ("JUL-15'") Group l.attribute1, C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8 UNION Select l.attribute1 LEGACY_ACCOUNT, C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8, JUN_15 TO_NUMBER('0'). TO_NUMBER('0') JUL_15. AUG_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)), TO_NUMBER('0') SEP_15. TO_NUMBER('0') OCT_15. TO_NUMBER('0') NOV_15. DEC_15 TO_NUMBER('0') Of b GL.gl_je_batches, GL.gl_je_headers h, GL.gl_je_lines l, GL.gl_code_combinations c, GL.gl_je_sources_tl j where b.je_batch_id = h.je_batch_id and h.je_header_id = l.je_header_id and l.code_combination_id = c.code_combination_id and h.je_source = j.je_source_name and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',) ('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337') and j.language = 'en '. and h.PERIOD_NAME ("AUG-15'") Group l.attribute1, C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8 order by 1 Is there a good reason to make this period both as a series of trade unions? This looks like a classic pivot for me query. This will make a way through the tables and should get the desired results. Select l.attribute1 legacy_account, c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' | c.segment4: '-' | c.segment5: '-' | c.segment6: '-' | c.segment7: '-' | combination of c.segment8, sum (case when h.period_name = 'JUN-15' then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00) otherwise 0 end) jun_15,. sum (case when h.period_name = 'JUL-15' then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00) otherwise 0 end) jul_15,. - and similar to DEC - 15 GL.gl_je_batches b, gl.gl_je_headers h, gl.gl_je_lines l. GL.gl_code_combinations c, gl.gl_je_sources_tl j where b.je_batch_id = h.je_batch_id and h.je_header_id = l.je_header_id and l.code_combination_id = c.code_combination_id and h.je_source = j.je_source_name and c.segment1 ('190', '191', '192', '193', '194', '195',' 196', ' 197', '198 ', '199', '200', '203', '205' ', 206',' 330 ', ' 331', "332 ', '333', '334', '335',' 336 ', ' 337') and j.language = 'en '. and h.period_name (' Jun-15', ' 15 JUL', ' AUG-15'... "" ") L.attribute1 group, c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' | c.segment4: '-' | c.segment5: '-' | c.segment6: '-' | c.segment7: '-' | c.segment8 If you're on the 11G version of the database, you might want to look at the PIVOT keyword that will do the same thing in a more concise expression. John How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column? n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine The select statement works by itself, but it fails as an INSERT... SELECT statement. Appreciate the help! Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select: SQL > insert into T1 (owner_name, pet_count) 3 lines were created. SQL > select * from t1; ID OWNER_NAME PET_COUNT SQL > Keep in mind index THAT MATERIALIZE is undocumented. SY. DDL lock on the object in a SELECT statement? Environment: Oracle 11.2.0.4 EE on Solaris My client called me when she was trying to create a new index on a table and the process was just hanging. Also, she was not able to DELETE an existing index on the same table, which deal with hang them as well. After reviewing the advice DBA_DDL_LOCKS, I found a DDL lock on the target of the index table. The DDL lock is held by a process doing a SELECT on the table and this process worked for several hours. There was no entry in V$ LOCKED_OBJECTS for the table. I don't know, yet, what other operations prior to the SELECT statement in the offending process, I have not heard of the user yet. I realize a DDL lock is placed on objects to prevent changes while specific operations are directed against this object, i.e. the DROP, UPDATE, compile the PACKAGE, etc. Question: Is a select also place a DDL lock on a table at a level that would avoid a new index is created or an existing index having fallen? Thank you very much for your comments! Any reference to the resolution is greatly appreciated. I searched some Concepts Developers Guide, SQL, even Google reference Guide. -gary > My question is now, this lock persists for the duration of the running query? Easy enough to show that it is not. Session1: Session 2: Note that I was able to remove the table even if select is still 'in progress' - the cursor is open. If you really want to blow your mind, go back to the session 1: The picture has gone, but I can always look for him. However, try again: Note that the forum software is stupid. is: followed by x. seems it's really important to have a smiley to lovey eyes in a technical forum. Edit - and when you format the SQL code, it is removed completely and render invisible... silly. I edited my code to use: X and the problem disappeared... SELECT statement in the script output window Hello SQL Dev 4.0.3 is it possible to include select statements from the command run the Script in the Script Output window? Is the result in the window: Select 1... ; results Select 2... ; results Joop try to put "set echo on" (without the quotes) as the first line and make sure that you use F5 to run the script... like sqlplus. I get the "No importable files" message when I try to download a webinar for editing mp4 file. I have try the MOV file and still no change. NEITHER USB-6212 is not detected on the USB bus. Hello We use an NI USB-6212. We had installed it and works correctly on a test system. Now it does not work and what are the symptoms: -When it is connected to the USB the led next to the connector bus is not turned on. -MAX software does not detect Status of the hard drive Test: Failed Failure ID: 908 40 - 6QL7 GA-MFPWXG-60FA03 Product ID: D3G93EA #ABV F2 Diaognostic give the error above message when trying to run the disk check. Impossible to install any windows OS it will take one to five hou Windows 7 - Error Codes: 66A & 80246007 (cannot install updates) Some updates won't install: Error (s) found: Code 66 A & Code 80246007 the two Codes met with unknown errors I can't open my windows photo gallery, he went, how to locate and recover? When I click on the windows icon library, a small window pops up with nothing in it, but the good word, when I click on the OK button it goes, but nothing opens.Similar Questions
I tried
SELECT name FROM dba_services
But a long with valid service, he list also some other documents that are not the names of services.
select name, value from v$parameter where name = 'service_names';
Best regards
Jean Valentine
I'm new to PL/SQL and I must get a procedure as parameter select SQL select statement as a VARCHAR and the production output the result of the statement with a few changes. Can someone help me solve this problem?
A possibility I thought at was to use a REF CURSOR. The following example works but binds me to a specific table (in the example of the "customers" table). However, I need the ability to specify arbitrary tables in the select statement parameter.
My idea was to modify this example to work in the following code, but it does not work (I get a compile error):SET SERVEROUTPUT ON
DECLARE
TYPE my_cur IS REF CURSOR;
query_cursor my_cur;
BEGIN
OPEN query_cursor FOR 'SELECT * FROM customers';
DECLARE
record_type customers%ROWTYPE;
BEGIN
LOOP
FETCH query_cursor INTO record_type;
EXIT WHEN query_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('some output ... ');
END LOOP;
END;
CLOSE query_cursor;
END;
/
Does anyone has an idea how can I solve my problem?SET SERVEROUTPUT ON
DECLARE
TYPE my_cur IS REF CURSOR;
query_cursor my_cur;
BEGIN
OPEN query_cursor FOR 'SELECT * FROM customers';
DECLARE
record_type query_cursor%ROWTYPE;
BEGIN
LOOP
FETCH query_cursor INTO record_type;
EXIT WHEN query_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('some output ... ');
END LOOP;
END;
CLOSE query_cursor;
END;
/
Thank you very much!
(I'm using Oracle 11 g)
Re: Dynamic Extraction on dynamic Sql
I need to use as a result of a SELECT statement in my function to get PCODE from the table. Cur_rec here. CODE comes from cursor that runs before the declaration.
SELECT PCODE in v_pcode TABLE_XYZ where CODE = cur_rec. CODE and PCODE = 'VIEW '.
Now the problem is the part of the CODE has all the information in the table TABLE_XYZ. In this case, it triggers an error NO_DATA_FOUND. To solve it, I can put a part of the EXCEPTION and handle it. But I think in another way...
If there is no data for a CODE, the default value of v_pcode would be 'No Code'. I tried to use the NVL function, but it does not work here as a SQL SELECT statement.
Can someone give an idea how to achieve this?
declare
...
v_cnt number;
begin
SELECT count(*)
into v_cnt
from TABLE_XYZ
where CODE = cur_rec.CODE
and PCODE='SEE';
if v_cnt=0 then
v_pcode = 'No code';
else
v_pcode = 'SEE';
end if;
end;
place names of columns?
Run SQL
Is it possibleselect AddressId,Name,City from Address
Thanks in advance select 1,2,5 from Address
with
SELECT Column_name
FROM user_tab_columns
where table_name = 'MY_TABLE'
and Column_id in (1,2,5)
I wanted to know, if the concept of loop is possible thanks to the SQL select statement.
For example
=======
Table T1
Col1 Col2
Slim 10
I want to write a query in such a way, so that when I get the result of the query, I format below.
Col1 Col2
Slim 10
Slim 10
Slim 10
Basically what I'm trying to achieve is, I have a table with two columns and it has a single line displayed above.
I want to display this line several times as the output of my SELECT query.
Let me know, if this target is achievable.
Kind regards
Saurabh
SQL> SELECT 10 col1, 'Sourabh' col2
2 FROM DUAL
3 CONNECT BY LEVEL <= 3;
COL1 COL2
---------- -------
10 Sourabh
10 Sourabh
10 Sourabh
SQL>
I would like to know how I can handle strings in a SQL select statement?
SQL > SELECT 'string' from dual
Her send me errors when the string is "or &." For example, as if string = Mike & Karen project
You can also tell me wht other characters, such as ', & can make a question?
Thank you.
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14251/adfns_sqltypes.htm#sthref377
Increase this setting to set lin 3000 or more.
My requirement is that.
I want to write a query and write a function, function, I want to return multiple columns at the same time in a Select statement.
I select the return values in the Select no statement in a PL/SQL block.
Is it possible to use the PL/SQL Table or Variable of Type record, or any other method in the statement Select?
Please help me understand the solution.
Kind regards
do we like it?
select t.col1,
t.col2,
f.col1,
f.col2,
f.col3
from table_name t,
table(some_table_function(param1,...paramN)) f
/
Set serveroutput on
DECLARE
v_item_type VARCHAR2 (20);
number of v_total_count;
v_approved VARCHAR2 (20);
number of v_apprv_count;
BEGIN
SELECT ITEM_TYPE, count (*)
IN v_item_type, v_total_count
Of
APPLSYS. WF_ITEMS
WHERE
ITEM_TYPE = "GLBATCH" AND
End_date is not null
ITEM_TYPE GROUP;
dbms_output.put_line ('Item_type: ' | v_item_type);
dbms_output.put_line ('Count: ' | v_total_count);
END;
BEGIN
SELECT B.ACTIVITY_RESULT_CODE, COUNT (*)
IN v_approved, v_apprv_count
Of
APPLSYS. WF_ITEMS, A.
APPLSYS. B WF_ITEM_ACTIVITY_STATUSES,
APPLSYS. FND_USER C.
APPLSYS. FND_USER D
WHERE
A.ITEM_TYPE = B.ITEM_TYPE AND
A.ITEM_KEY = B.ITEM_KEY AND
A.ITEM_TYPE = "GLBATCH" AND
A.END_DATE is not null AND
A.OWNER_ROLE = C.USER_NAME and
B.ACTIVITY_RESULT_CODE = "APPROVED" AND
B.ASSIGNED_USER is not null and
B.ASSIGNED_USER (+) = D.USER_NAME
GROUP BY b.activity_result_code;
dbms_output.put_line (' approved: ' | v_approved);
dbms_output.put_line ('Count: ' | v_apprv_count);
END;
Declare
v_item_type Varchar2(20);
v_total_count Number;
v_approved Varchar2(20);
v_apprv_count Number;
Begin
-- First SQL
SELECT ITEM_TYPE
,Count(*)
INTO v_item_type
,v_total_count
FROM APPLSYS.WF_ITEMS
WHERE ITEM_TYPE = 'GLBATCH'
AND END_DATE Is Not Null
Group BY ITEM_TYPE;
dbms_output.put_line('Item_type: ' || v_item_type);
dbms_output.put_line('Count: ' || v_total_count);
-- Second SQL
SELECT B.ACTIVITY_RESULT_CODE
,Count(*)
INTO v_approved
,v_apprv_count
FROM APPLSYS.WF_ITEMS A
,APPLSYS.WF_ITEM_ACTIVITY_STATUSES B
,APPLSYS.FND_USER C
,APPLSYS.FND_USER D
WHERE A.ITEM_TYPE = B.ITEM_TYPE
AND A.ITEM_KEY = B.ITEM_KEY
AND A.ITEM_TYPE = 'GLBATCH'
AND A.END_DATE Is Not Null
AND A.OWNER_ROLE = C.USER_NAME
AND B.ACTIVITY_RESULT_CODE = 'APPROVED'
AND B.ASSIGNED_USER Is Not Null
AND B.ASSIGNED_USER(+) = D.USER_NAME
Group BY b.activity_result_code;
dbms_output.put_line('Approved: ' || v_approved);
dbms_output.put_line('Count: ' || v_apprv_count);
End;
Christian BalzThe LEGACY ACCOUNT ORACLE ACCOUNT JUN_15 JUL_15 AUG_15 SEP_15 OCT_15 NOV_15 DEC_15 010000001109000003584 190-600552-1001-100231-000-0000-0000-0000 0 0 -242961.04 0 0 0 0 010000001109000003584 190-600552-1001-100231-000-0000-0000-0000 0 192588.02 0 0 0 0 0 IDENTITY
column. Even if the INSERT... SELECT
statement works on most SELECT
uses I tried, if this statement was also a GROUP BY
clause, it does not work, delivering a "ORA-00979: not a GROUP BY
expression ' complaint. Some examples of code:
create table aux ( owner_name varchar2(20), pet varchar2(20) );
insert into aux values ('Scott', 'dog');
insert into aux values ('Mike', 'dog');
insert into aux values ('Mike', 'cat');
insert into aux values ('John', 'turtle');
create table T1 (
id number generated always as identity,
owner_name varchar2(20),
pet_count number );
insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work
2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
3. Select owner_name, pet_count t
4.
---------- -------------------- ----------
1 John 1
Scott 2 1
3 Mike 2
SQL> create table foo(bar number);
Table created.
SQL> insert into foo values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> variable x refcursor
SQL> variable a number
SQL> begin
2 open :X for select bar from foo;
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> drop table foo;
Table dropped.
SQL> begin
2 fetch :X into :a;
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> print a
A
----------
1
SQL> /
begin
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
Maybe you are looking for