Force Query To Always Bring Back Certain Amount Of Rows

Jun 24, 2010

Is there a way to force a query to ALWAYS bring back a certain amount of rows, even if some of the rows are blank?

I know there's a way in MSSQL but not sure how to in SQL+

View 7 Replies


ADVERTISEMENT

SQL & PL/SQL :: Write Outer Query Which Will Bring Individual Records Which Don't Sum Up To Zero

May 9, 2011

I have to write a sub query / build a logic for the below.

There are several accounts which should have a zero balance i.e sum of all the amoutns in that account should be zero. If they are non zero , i have to report which amounts make up non zero balance.

If i have amts as +20 , -20 , -30,-10 i.e the sum is -40 indicating a non zero amount. I need the entire details of the records which makes up non zero sum. So in above case details related to -30 aand -10.

I'm using a sum group clause on several fields at which sum is required to be checked ie. date , account , currency . query that will bring individual records that don't make the sum zero.

Is it possible to write a outer query which will bring individual records which don't sum up to zero.

View 14 Replies View Related

Query To List Employee Number And Amount Of Days Sick

Apr 19, 2009

I have been trying to construct a query in Oracle that allows me to do the following:

For example if I have the data below:

EmpNo DOB SickDays
Alex 445 15/06/1985 7
Tom 778 22/08/1981 4
James 992 07/10/1978 5

I need to write and a query to lists the employee number and the amount of days sick that they have had and also add a column that compares the number of sick days to the average number of suck days by ALL employees.

I can calculate the average sick days etc, but It wont see to allow me to find the difference between that and the amount of sick days that each person has had. I have tried this many ways and have not been able to come up with a solution.

View 3 Replies View Related

SQL & PL/SQL :: Write A Query To Combine Amount1 And Amount1 Into Single Column Amount?

Aug 3, 2011

How can I write a query to combine amount1 and amount1 into single column amount?

create table a (
id_code varchar(20),
invoice_date date,
invoice_type number,
interest number,
advance number,
invoice number
);

[code]....

View 7 Replies View Related

Enterprise Manager :: Unable To Bring Up OEM When Using Different Pfile

Jun 5, 2010

what is missing in this pfile that would cause enterprise manager not to appear ?

In the Oracle Database 10g: Administration Workshop II The chapter 8 excercise calls for the database to be started using the pfile init_sgalab.ora . The purpose of this I suppose is to simulate a memory error.

When I get to the part where I need to use OEM to fix the problem, OEM does not come up. The contents of init_sgalab.ora are :
--------------------------------------------
background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
compatible='10.2.0.1.0'
control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl /control03.ctl'
core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
db_block_size=8192
[code].......

I am not sure what is missing in this file to be able to bring up OEM.

Also, I looked at the logs and this is the only error message I found that might be relevant in

/u01/app/oracle/product/10.2.0/db_1/jhlinux.home.com_orcl/sysman/log/emoms.log

2010-06-04 23:33:59,809 [HttpRequestHandler-8546123] ERROR eml.OMSHandshake processFailure.619 - OMSHandshake failed.(AGENT URL = http://jhlinux.home.com:3938/emd/main)(ERROR = INTERNAL_ERROR)

View 24 Replies View Related

Server Administration :: ORA01403 Bring A Database Down?

Jul 8, 2011

We came in this morning with one of the servers down. After bringing it back up and checking the alert log, the only indicators that something was wrong were the hundreds of ora_01403 and the resulting trace files that were created.

The trc files for the most part indicated 'knpssamsg encountered 1304; end of error statck dumped in slave;' date and time and service name being sys$users.

View 4 Replies View Related

Bring Record To Top Without Changing Ascending Order Of Dep-id?

Jul 18, 2010

i have a table named employees in which there are 2 columns dep_id and name. One record having name as annie has dep_id=null .

When i arrange the records of the table in ascending order using order by dep_id the record with name annie and dep_id is placed in the last because null is consired largest. How can I bring that record to the top without changing the ascending order of the dep_id.

View 7 Replies View Related

Bring Down The Databases In Oracle Fail Safe Environment?

Jun 28, 2013

How can we bring down the databases in oracle fail safe environment?

We have one database X in two server�s windows A & B with oracle fail safe environment.
What procedure should we fallow to bring down the database X.

Today I was strangling to bring down the database because database was automatically coming up once brought down the database. what procedure should we follow to bring down the database in OFS environment.

View 1 Replies View Related

SQL & PL/SQL :: Query Using DBLink Returns More Rows Than Direct Query?

Apr 6, 2010

I have a query that is pulling back more rows when I use the dblink than when I hit the linked database directly.

For example:

select
x,y,z
from
mytable@dblink

returns 788,324 rows

while
select
x,y,z
from
mytable

returns 712,102 rows

It's the exact same query, with the only difference being the dblink. It's not pulling the data into a cursor or array, it's a simple, straightforward query on a remote database.

View 10 Replies View Related

SQL & PL/SQL :: Does Force View Option Works In Oracle 11g

Aug 13, 2010

when i am trying to excute below query.. it says ORA-00942: table or view does not exist.

create or replace force view v2 as select * from employee;

View 11 Replies View Related

Performance Tuning :: Force Subquery To Use Index?

Aug 5, 2010

I have the following query:

Select
tag0.TAG_VALUE pid, tag1.TAG_VALUE, tag2.TAG_VALUE From TAGGER.TAGGABLE_RESOURCE r
, TAGGER.TAG tag0
, TAGGER.TAG tag1
, TAGGER.TAG tag2
where 1=1

[code]....

This runs in about 400ms. Now I replace this:

ANDtag0.TAG_TYPE in (4602, 5228)
ANDtag1.TAG_TYPE in (4612, 5225)
ANDtag2.TAG_TYPE in (4613, 5226)

with this:

ANDtag0.TAG_TYPE in (select COLUMN_VALUE from ( select * from table( TAGGER.GET_IDS_OF_SIMILAR_TAG_TYPES('Patient ID') ) x1 ))
ANDtag1.TAG_TYPE in (select COLUMN_VALUE from ( select * from table( TAGGER.GET_IDS_OF_SIMILAR_TAG_TYPES('Patients Sex') )x2 ))
ANDtag2.TAG_TYPE in (select COLUMN_VALUE from ( select * from table( TAGGER.GET_IDS_OF_SIMILAR_TAG_TYPES('Patients Birth Date') ) x3 ))

So instead of hard coding the IDs there is a function that looks them up. The function itself is reporting that it runs in 0ms. But when I run the new query:

Select
tag0.TAG_VALUE pid, tag1.TAG_VALUE, tag2.TAG_VALUE From TAGGER.TAGGABLE_RESOURCE r
, TAGGER.TAG tag0
, TAGGER.TAG tag1
, TAGGER.TAG tag2
where 1=1

[code]....

it takes around 6s to run. I have looked at the explain plans it it seems as though the function based approach is triggering a full table scan of 'TAG'.

I have tried it with query hints to use index, but it doesn't change the execution plan, or the query time.

The explain plan for the quick query is:

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------
Plan hash value: 1031492929
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

[code]....

And the slow one is:

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 2741657371
----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |Te
----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 20M| 1602M|

[code]....

View 5 Replies View Related

Force View Number Data Type Precision?

Aug 18, 2011

I am working on an application that pulls data from an Oracle view into Microsoft Excel (Oracle 11g, MS Excel 2003). It is an automated pivot table created through vba. The problem I'm having is that the decimal points from number columns are being truncated - they don't make it to the pivot table.

When I use the pivot table wizard and set the external data source using a SQL string (select * from view), the precision is not lost. When I create the pivot table automatically in vba, the precision is lost. The pivot table settings, regardless of how the data is brought in, shows the format of the number column as general. This tells me that Excel is trying to figure out what the data type is, and can't (not smart enough).

When looking at the description of the view, the data type is NUMBER (no precision). The table that it is pulling from has the precision set (NUMBER(11,3)). I have tried using the following, but it doesn't work:

select to_number(field_name, '99999999.999') field_name from view

View 7 Replies View Related

Performance Tuning :: Force Optimizer To Consider All Join Permutations?

Oct 14, 2013

I'm looking to see if there is a way (fully expecting it to be an underscore, or two...) to force the optimizer to keep churning until all permutations are exhausted.I'm aware that it, to paraphrase, cuts out when it's spent more time parsing than it would just running it based on it's estimates.

I've got some irritating problems with xml rewrite, xml indexes and access paths/cardinalities etc and I'm really needing the entire thing considered as a one off for debugging this. I've already cranked up the maximum permutations to the max but it's not enough, it shorts out after 5041 permutations (I'd set that to 80000 max).

I know you'd not want to do this in the real world but I cant get the damned thing to run the plan I want in a 10053 so I can see the values it has there. I know I can hint it, but I'm trying to ascertain why it's not even considering it in a "normal" parse.

View 6 Replies View Related

Performance Tuning :: How To Force SQL To Use Index Range Scan

Jul 15, 2011

How can i force a sql use index range scan?

View 10 Replies View Related

Performance Tuning :: Force Index Unique Scan?

Jun 14, 2012

Is there any hint to force "Index Unique Scan" over "Index Range Scan".

My query is generating different plans with the above two, and very slow when it uses "Index Range Scan".

View 19 Replies View Related

Forms :: How To Force User To Enter Exactly 3 Digits Into Number Field

Mar 28, 2011

There is a text item on my form with NUMBER data type. I want to force the user to enter exactly 3 digits in to that text item. My current FORMAT MASK is set to 990. But this allows user to enter even a single digit where as my requirement is user should enter exactly 3 digits. Can we achieve this by changing the FORMAT MASK property?

View 6 Replies View Related

SQL & PL/SQL :: Query To Get Columns Into Rows?

Aug 10, 2010

I have one issue with the converting columns into rows.

Employee table has manager , additional manager and some other columns. If the employee has additional manager, then i need those employee record with 2 rows : 1st row - manager with other data , 2nd row - additonal manager with other data .

Orginal data is like this:

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ADDTIONAL_MGR ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- -------------
7369 SMITH CLERK 7902 17-DEC-80 800 20 7698

[code]....

I have tried this , using UNION ALL method, But it is taking more time.

SQL> ED
Wrote file afiedt.buf
1 SELECT DECODE (DUMMYTAB.NUM,'1',MGR, '2',addtional_mgr) MANAGER, empno, ename, job, hiredate, sal, comm, deptno
2 FROM emp E, (SELECT '1' NUM FROM DUAL UNION ALL SELECT '2' NUM FROM DUAL) DUMMYTAB
3* WHERE addtional_mgr IS NOT NULL
SQL> /

View 15 Replies View Related

SQL & PL/SQL :: Update Query For 2 Lac Rows

Jun 12, 2013

I have 2 tables with 3 common columns (Col1, col2,Primary). One common column name is primary (oracle key word).Around 2 lakhs rows to be updated and No indexes are used on these tables. I need to write an update query as shown below.

Emp table

Col1col2primay
100101y
103104n
201105y
100101y

Dept table

Col1col2primay
100101null
103104null
000656null

Update query Result

Col1col2primary
100101y
103104n

View 16 Replies View Related

PL/SQL :: Query - Rows In Columns

Jul 27, 2012

I have following table -

CREATE TABLE     group_device
( group_id          NUMBER (8)     NOT NULL
, member_id     NUMBER (4)     NOT NULL
, device_id     NUMBER (10)     NOT NULL
, install_date     DATE           NOT NULL
, remove_date DATE
);

[Code]...

Current output does looks like below

10     1     123     23-MAY-12     28-MAY-12
10     1     456     28-MAY-12     01-JUN-12
10     1     789     01-JUN-12     
10     2     999     04-MAY-12     17-MAY-12
10     4     1123     22-JAN-12     27-JAN-12
10     4     1456     27-JAN-12     28-JAN-12

Device_id - Replaced_device_id - remove_date :: For group_id=10

e.g. for member_id = 1, device_id=123 got replaced by device_id=456 on 28-May-12
               device_id=456 got replaced by device_id=789 on 01-Jun-12

So output should look like this

10     123     456     28-May-12     -- Replaced     
10      456     789     01-Jun-12     -- Replaced     
10     789                    -- Active

Similarly there will be many groups, so it should list based on group_id

View 8 Replies View Related

Client Tools :: Force Parameter Value To Change Filename For Every Execution Of Sql Script

Jan 24, 2012

I wrote an sql script (spooler) which runs a select query and produces results into a file.

I want to have the filename with the year attached. Can i pass a parameter when i run the script from SQL*PLUS

@'B: Year Of FinancingPLSQLspoolersSpooler_File_Creation' 01/01/2010 2010;

the first parameter 01/01/2010 is passed to the select query and taht works fine.

Since the output file contains 2010 data, I want the spooled file to mention in its name the 2010, so User's can know the file contains 2010 data in it.

So i wrote the statement within the spooler script

SPOOL X:HARSOrganizationsFinancialDataFor&2.txt

&2 should take 2010 has its value and produce the file FinancialDataFor2010.txt

how to use Substitution variables to produce the Filename i want.

View 10 Replies View Related

Forms :: Force User To Save Or Discard Record Before Child Window?

Aug 10, 2012

I have created a form where the main canvas has number of buttons. When I click each button it will open a new canvas in a new window. User will enter some details there. now I want to force the user to save or discard the record before they leave that child window. The code I have written is

DECLARE
n_button_selection INTEGER;
BEGIN
IF :SYSTEM.BLOCK_STATUS = 'CHANGED' then

[code]...

But I am not sure in which trigger I need to write the code. When I am writting in post block it is behavior is becoming unpredictable and also APP_STANDARD.EVENT('KEY-COMMIT') does not work in post_block trigger. When I am writting this in ON close trigger then also it is not firing as expected.

View 1 Replies View Related

Application Express :: How To Force APEX To Fire Submit After Processes Before On-Demand

Jul 2, 2013

We have an application that has "After Submit" and AJAX "On-Demand" processes.  We need the "After Submit" to fire and complete first, set an application item (by referencing the next value in a sequence), and then fire the "On-Demand" processes.  We have the sequence number set accordingly, with all of the "After Submit" processes given a lower (APEX) sequence number than the "On-Demand" processes; however, it seems the "After Submit" processes are still not firing and completing because only intermittently are the "On-Demand" processes able to access the application item's value--80% of the time this value is simply blank.  Making matters more complicated is that the application item is derived from an Oracle sequence, so in my "On-Demand" processes, I cannot simply re-run some of the same logic used in one of the "After Submit" processes that sets the sequence--the sequence may only be set once, and only by this "After Submit" process; we have no choice in that regard. Is there any way possible in APEX to 100% force processes to fire AND complete, one after another, in the order in which they are listed by their (APEX) sequence?  In other words, if we have this: 

(APEX) Seq Name & Process Type

1 process A ("After Submit")  
2 process B ("After Submit")--this sets application item :XYZ
3 process C ("On-Demand)--this uses application item :XYZ and MUST have this item value available to do any processing Can we instruct APEX to fire process A, complete it, fire process B, complete it, and only then, fire process C? 

View 2 Replies View Related

Converting Query Rows Into Columns?

Sep 14, 2008

I have seen lots of examples of using PIVOT to return an sql query where the rows have been converted to columns. All the examples I can find require you to have two columns with multiple rows, and also require you to know the data which is in one of columns to make titles for the new columns.

I need something a little different...I have a query using UNION which goes something along the lines of...

SELECT [get data from one place]
UNION
SELECT [get data from another place]
UNION
SELECT [get data from another place]

this returns the following...
a_val
-----
100
200
300

query to return something like this...
a_val1 a_val2 a_val3
------ ------ ------
100 200 300

The names of the columns don't really matter. And I dont want to create a new table in the database just for the result.

View 1 Replies View Related

Select Number Of Rows From Query?

Jun 13, 2007

In sql plus How do I get the number of distinct rows of a certain value?

for example

select group_number from records group by group_number

How would I query for the total number of group_numbers in this query?

View 2 Replies View Related

SQL & PL/SQL :: How To Convert Query Columns Into Rows

Jun 19, 2013

the query used is

SELECT LOC_CD,
TO_CHAR(DT,'fmMon RRRR'),
SUM(QTY) ,
GROUPING_ID(LOC_CD)
FROM WIP
WHERE LOC_CD IN (1,2,3,4)
GROUP BY ROLLUP(LOC_CD),
TO_CHAR(DT,'fmMon RRRR'),TRUNC(DT,'MM')
ORDER BY TRUNC(DT,'MM'),LOC_CD

This query result attached

The red coln is the total I want to place it in row-wise

Date loc_1 loc_2 loc_3 loc_4 Total
May 2012 4,554 6,644 11,198
June 2012 4,986 5,838 777 11,601
22,799

View 1 Replies View Related

SQL & PL/SQL :: Show Missing Rows In Query

Feb 7, 2012

SQL> select * from t1;

NAME
----------
JACK
JOHN
JENN

SQL> select * from t2;

NAME
----------
JACK
PAUL

SQL> select a.name from t1 a, t2 b where a.name <> b.name
2 order by name;

NAME
----------
JACK
JENN
JENN
JOHN
JOHN

I would have expected to see the following:

name
-----
JOHN
JENN
PAUL

how to fix this query? In additon, is there a way to print the table name or some arrows (>>, <<) to show which table the values came from

I.e

name
=====
JOHN t1 or <<
JENN t1 or <<
PAUL t2 or >>

View 14 Replies View Related

PL/SQL :: Limit Order By Rows Without Using Sub Query

Sep 4, 2013

Here is my query to fetch only 10  records from order by result set. 

select *from (select * from EOE_POC.PRODUCT_TEST_REPORT where PRODUCT_CODE='214d' order by CREATE_DATE desc ) where ROWNUM <= 10  

I am having problem binding it with java API . how to query this without using sub query ?

View 11 Replies View Related

SQL & PL/SQL :: Query To Convert Rows Into Column

Dec 11, 2009

I need a single select query which converts all the rows into a single value . Below is my requirement :

Create table email_tbl(emailid varchar2(30));
insert into email_tbl('1@y.com');
insert into email_tbl('2@y.com');
insert into email_tbl('3@y.com');
insert into email_tbl('4@y.com');

Now , I need a single select query which gives me the below results.

1@y.com,2@y.com,3@y.com,4@y.com

I have done the above by using a cursors in the pl/sql objects.But want to achieve this with a single sql/query.

View 7 Replies View Related

SQL & PL/SQL :: Query To Return Two Different Concatenated Rows

Jan 10, 2012

I have not found a solution for this, but it could be that I don't know what to search for.

I need to edit the following statement:

SELECT a.id||a.name||a.amount*2 as transaction
FROM a
WHERE a.amount IN (500, 1000)

To return:

TRANSACTION
------------------------------------
123SMITH1000
123SMITHADJUSTED AMOUNT PER X
456JONES2000
456JONESADJUSTED AMOUNT PER X

The returned rows need to be in this format to be executed in another database.

Can this be done?

View 8 Replies View Related

PL/SQL :: Sql Query To Convert Rows To Columns

Feb 19, 2013

Im using oracle 11g.

I have data in a table as below: Column names are type,month,percentage

TYPE      MONTH   PERCENTAGE

A1         JAN-2013     100
A2         JAN-2013     100
A3         JAN-2013     95
A4         JAN-2013     98

[Code]...

The desired output using a sql query is as below

TYPE     JAN-2013     FEB-2013
A1         100             100
A2         100             99
A3         95               88
A4         98               67
A5         99               98
A6         90               95
A7         92               84

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved