SQL & PL/SQL :: Only Adding Order By Row Count

Sep 15, 2010

select bill_no from bill_mst is showing 25 records.

select bill_no from bill_mst order by 1 is showing 5 records.

View 13 Replies


ADVERTISEMENT

SQL & PL/SQL :: Query Gets Slower By Adding Order By Clause

Apr 14, 2010

I have a query, running the query with order by and without orderby clasue casues big performance difference.

here without order by it takes 5 sec
.
SELECT
audit_number,
formatted_audit_number,
ag.sys_audit_id,
audit_begin_date,
audit_end_date,

[Code]....

here with order by it takes 2 min

SELECT
audit_number,
formatted_audit_number,
ag.sys_audit_id,
audit_begin_date,
audit_end_date,
auditee_name,
ein,

[Code]....

I have like 10,000 records.

View 16 Replies View Related

PL/SQL :: Adding Columns To Count Contents Of Other?

Aug 31, 2013

how to incorporate counts into my current SQL code  that would count food items, and then car items for each person. Once I understand this concept I hope to apply it to my real database (in Oracle) where I am counting medications and problems for each patient.For example using my test data below, the my goal would be to have count columns show that Cathy had 3 food count and a 1 cars item (the count would need to ignore the null values in these  columns). I don't really care if the count value repeats in every row for that person.

 Select data1.Name, data1.Category,Data1.Results,Case When data1.Category IN ('food') then data1.results end FOOD,Case When data1.Category IN ('Cars')then data1.Results end CARSFROM(Select T1.name Name, null Category, null Results from a_Main T1, a_Food T2 Where T1.cpi_seq = T2.CPI_SEQUNION Select T1.name, 'food', T2.Food  from a_Main T1, a_Food T2 Where T1.cpi_seq = T2.CPI_SEQUNIONSelect T1.name, 'cars',  T3.Cars  from a_Main T1, a_Cars T3 Where T1.cpi_seq = T3.CPI_SEQ)data1where data1.Category is not nullorder by Name,

[code]....

View 2 Replies View Related

Performance Tuning :: Order Of Steps In Execution Path And Order Of Predicates In The Plan

Mar 20, 2012

Which step in the following plan is the first step of execution

I reckon it is "TABLE ACCESS BY INDEX ROWID| BANK_BATCH_STATE"

Is that correct?

In the "Predicate Information (identified by operation id):"

section the predicates - access and filter for the step "TABLE ACCESS FULL | PYMNT_DUES" are displayed first

Isn't there any relation between the order of execution steps and the order in which predicates are displayed?

Execution Plan
----------------------------------------------------------
Plan hash value: 538700484
-------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2364 | 15 (14)| 00:00:01 |
|* 1 | FILTER | | | | | |
| 2 | HASH GROUP BY | | 1 | 2364 | 15 (14)| 00:00:01 |
| 3 | NESTED LOOPS | | 1 | 2364 | 14 (8)| 00:00:01 |
| 4 | NESTED LOOPS | | 1 | 2313 | 13 (8)| 00:00:01 |
| 5 | NESTED LOOPS | | 1 | 2281 | 12 (9)| 00:00:01 |
| 6 | NESTED LOOPS OUTER | | 1 | 2255 | 11 (10)| 00:00:01 |
|* 7 | HASH JOIN | | 1 | 175 | 6 (17)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | INDX_2 | 12 | 612 | 2 (0)| 00:00:01 |
|* 9 | TABLE ACCESS FULL | PYMNT_DUES | 43 | 5332 | 3 (0)| 00:00:01 |
| 10 | VIEW PUSHED PREDICATE | | 1 | 2080 | 5 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 154 | 5 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 103 | 4 (0)| 00:00:01 |
|* 13 | TABLE ACCESS BY INDEX ROWID| BANK_BATCH_STATE | 1 | 32 | 2 (0)| 00:00:01 |
|* 14 | INDEX RANGE SCAN | INDX_BBS_1 | 3 | | 1 (0)| 00:00:01 |
|* 15 | TABLE ACCESS BY INDEX ROWID| DAILY_CHECK | 1 | 71 | 2 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | INDX_SEARCH | 1 | | 1 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | INDX_2 | 1 | 51 | 1 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | INDX_IAM_SR_NO | 1 | 26 | 1 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | INDX_2 | 1 | 32 | 1 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | INDX_2 | 1 | 51 | 1 (0)| 00:00:01 |
-----------------------------------------------------------------

View 3 Replies View Related

SQL & PL/SQL :: Result Order In 2 Table Joins Without Order By

Sep 6, 2011

I have below tables,

describe rpthead

Name Null Type
--------------------------- -------- -------------
RPTNO NOT NULL NUMBER
RPTDATE NOT NULL DATE
RPTD_BY NOT NULL VARCHAR2(25)
PRODUCT_ID NOT NULL NUMBER

describe rptbody

Name Null Type
------------- -------- -------------
RPTNO NOT NULL NUMBER
LINENO NOT NULL NUMBER
COMMENTS VARCHAR2(240)
UPD_DATE DATE

The fact is that we store some header in RPTHEAD and store real data in RPTBODY, the question is that if I use below SQL to query all data for a 'PRODUCT_ID'.

SELECT t0.LINENO, t0.COMMENTS, t0.RPTNO, t0.UPD_DATE
FROM RPTBODY t0 , RPTHEAD rpthead
WHERE
(
t0.RPTNO = rpthead.RPTNO
AND
t0.UPD_DATE>=to_date('1970/01/01 00:00:00','YYYY/MM/DD hh24:mi:ss')
AND
rpthead.PRODUCT_ID IN ('4647')
)

I do not want to have 'ORDER by' clause since data set is too large, the sorting takes long time, is there any way to get the result rows in the order sorted by RPTNO? We have the index for RPTNO on RPTBODY.

View 5 Replies View Related

SQL & PL/SQL :: Difference Between Count(*) And Count(1)?

Nov 16, 2009

When we execute select count(*) from table_name it returns the number of rows.

What does count(1) do? What does 1 signifies over here? Is this same as count(*) as it gives the same result on execution?

View 13 Replies View Related

SQL & PL/SQL :: Difference Between Count(1) And Count(*)

Nov 24, 2011

difference between count(1) and count(*). As i know count(*) will give number of rows irrespective of null and count(1) will not count the null.My Oracle version is 10 g.

SQL> select * from t1;

A B C
---------- -------------------- --------------------
1 2 3
2
5

SQL> select rownum,a.* from t1 a;

ROWNUM A B C
---------- ---------- -------------------- --------------------
1 1 2 3
2 2
3 5
4
[code]....

View 3 Replies View Related

SQL & PL/SQL :: Adding Rows Value

May 28, 2013

I am having the following table and values.

A | B
=====
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5

I need an output in following

A | B | C
=========
1 | 1 |
2 | 2 | 3 --> 1+2
3 | 3 | 6 --> 3+3
4 | 4 | 10 --> 6+4
5 | 5 | 15 --> 10+5

I mean add the first row of column b with second row of column ==> this output need to show in column c

again this output need to add with third row of column b .......

any sql commands / keywords for this

View 2 Replies View Related

Adding Column With Default Value?

Jul 11, 2007

how do I add a column to an existing table which when rows are added to the table this column will have the same default value?

alter table thetable add (new_column_name varchar2(100) default bbubu);

View 1 Replies View Related

Adding Column If It Does Not Exist?

Mar 31, 2010

I've been trying to write some code to add a column if it does not exist as the code will be run numerous times and will be parameterized in other software to run across multiple tables.

Here is what I have made so far:

DECLARE
COLEXISTS integer;
vCmdStr varchar2(4000);

[Code]....

I can't figure out where the invalid character is.

View 3 Replies View Related

SQL & PL/SQL :: Adding High And Low To Zip Plus Four Values?

Jan 19, 2011

I have a table with zip codes and their plus four values. For ex: zip code of 10000, which has corresponding plus four values of 001, 002, 003, and 008, 009, 010. The issue is just that--a zip code can have sequential plus four values, and then it will skip several potential plus four values, and then start again. I would like to assign a low plus 4 value and high plus four value to a zip code, keeping in mind that the plus four values are not always sequential. So, it would be similar to this:

zip plus4 low plus4 high
10000 001 003
10000 008 010

View 2 Replies View Related

SQL & PL/SQL :: Updating Nth Row And Adding Column

Aug 7, 2012

I had created a table which have 100s' of entries in it.

create table reg_user
(
USERNAME VARCHAR2(50),
PASSWORD VARCHAR2(20)
)
***

[Code]..

1. In this table, how to update the Nth row, how can I do it

2. Now I need to add USERID in this table,which will get value from 1 to max no. of rows. I do not want to drop the table and again re create it adding USERID or update each row manually. Is there any other way to add USERID and have IDs from 1 to max IDs.

View 30 Replies View Related

RAC & Failsafe :: Adding New ASM Disk

Dec 23, 2012

I have DB on cluster and it set to active/active. ASM disk currently using raw device and connect to SAN storage. So i want to add new ASM disk on current environment.

Does oracle have this doc? What i can see from their said just show adding new ASM to new installation. Does it same as adding new ASM disk to current system? Does it success on implementation?

View 1 Replies View Related

SQL & PL/SQL :: Adding Conditions In Where Clause

Oct 20, 2010

I am trying to run an SQL query which refers/joins around 10 tables.In my case I would want to add an if-else or case condition in the WHERE clause of select query

For example

select a.column1, b.column1, c.column1, d.column1
from a, b, c, d
WHERE a.column2 = b.column2
AND (if a.column3 = 10 then ( I want 2 conditions to be
AND b.column2 = c.column2) added
else after WHERE clause as AND...)
AND b.column2 = d.column2
)
AND d.column2 = a.column2

View 5 Replies View Related

SQL & PL/SQL :: Adding IF Statement To A Trigger

Jan 8, 2013

I have created the below trigger in Oracle to ensure that a value in a table remains at 180 but I need to restrict this to one row in this table. Is there a way to use an IF statement or a where clause of some type for a particular row in that table? The Row is called ADMIN. Triggers weren't covered in my course so only know a few basic statements.

CREATE OR REPLACE
TRIGGER DAYSAGO_trg
BEFORE UPDATE ON days_ago
FOR EACH ROW
BEGIN
:NEW.days_ago := 180;
END;

View 4 Replies View Related

Adding A New Node In Oracle RAC

Aug 8, 2011

When I added a new node to RAC (existng 2 windows server 2008 R2 nodes), using the command,

CODEaddNode -silent
"CLUSTER_NEW_NODES={node3}" "CLUSTER_NEW_PRIVATE_NODE_NAMES={node3}"
"CLUSTER_NEW_VIRTUAL_HOSTNAMES={node3-vip}"

the output was "The cluster node addition <path> was successful".

But when I tried the following command,

CODEcluvfy stage -post nodeadd -node3

I got an error stating

QUOTE "ERROR: Shared resources check for node addition failed

The following node is not in cluster: node3

Post-check for node addition was unsuccessful on all the nodes."

When I checked the inventory logs, I found the following entry

QUOTE SEVERE:

oracle.sysman.oii.oiix.OiixException: The Oracle home '<path>' could not be updated as it does not exist.
at oracle.sysman.oii.oiic.OiicBaseInventoryApp.getOracleHomeInfo(OiicBaseInventoryApp.java:645)
at oracle.sysman.oii.oiic.OiicUpdateNodeList.doOperation(OiicUpdateNodeList.java:206)
at oracle.sysman.oii.oiic.OiicBaseInventoryApp.main_helper(OiicBaseInventoryApp.java:790)
at oracle.sysman.oii.oiic.OiicUpdateNodeList.main(OiicUpdateNodeList.java:399)

View 1 Replies View Related

SQL & PL/SQL :: Adding Number In Sysdate

Apr 26, 2013

Can we add 10000 days in SYSDATE using + operator ?

Quote: This I can test it but I don't have database access now that's why I am asking this question

View 5 Replies View Related

PL/SQL :: Timestamps - Extra Zero Are Adding?

Jul 8, 2013

view the below select statement..why it's adding extra zero's...

select to_timestamp('2001-05-22 12:00:18.600','YYYY-MM-DD HH:MI:SS.ff3AM') from dual
output: 5/22/2001 12:00:18.600000000 PM ---why it's adding extra zeors's
my output should be as " 5/22/2001 12:00:18.600 PM"

View 4 Replies View Related

Adding Check After Table Creation

May 23, 2009

I created a table but I want to add the Unique check to it as I forgot to apply it to the table when I created it.Is it possible to make the field Unique after having created the table or do I have to drop the table and re-create it?

View 3 Replies View Related

Adding Up Time Values In Varchar2?

Mar 6, 2009

column name: extra_hour

datatype: varchar2(5)

extra_hour
----------
01:30
01:30
00:00
02:45
and so on...

Problem: I want to add up all the given value and display it in a select statment, that is the output should be:

Output:

XXXXXX
----------
05:45

View 4 Replies View Related

Adding Column To Large Table

Aug 12, 2013

I want to add column to table which has huge amount of data and fill with data from another table. What is the best way to do it? Is it faster to use CTAS instead of ALTER TABLE ADD COLUMN?

View 2 Replies View Related

Adding Description On Lookup Table?

Aug 17, 2012

Ive got a look up table and i want it to display text instead of just the ID number, how would i do that? so for example if

1 = Hello
2 = Bye

it would display "Hello" instead of "1"

View 8 Replies View Related

SQL & PL/SQL :: Adding A Column Between Existing Columns

Jul 8, 2010

I want to add some new columns in an existing table that has over 10 millions rows, but not at the end of existing columns, my requirement is such i want new columns between existing existing columns. Is it possible.....

View 16 Replies View Related

Server Administration :: Adding Disk In ASM

Oct 16, 2012

I checked and found we have disk that is assigned with 0 disk GROUP_NUMBER. What does that mean ? how to check if disk T1_ASM05 is been part of any disk group or not.?

SQL> select GROUP_NUMBER,NAME from v$asm_diskgroup;

GROUP_NUMBER NAME
------------ ------------------------------
1 DATA
2 FRA
SQL>
SQL> select GROUP_NUMBER,name,PATH from v$asm_disk;

GROUP_NUMBER NAME PATH
------------ ------------------------------ -------------------------
1 T1_ASM01 ORCL:T1_ASM01
2 T1_ASM02 ORCL:T1_ASM02
0 ORCL:T2_BACKUP01
0 ORCL:T1_ASM04
0 ORCL:T1_ASM03
0 ORCL:T1_ASM05

6 rows selected.

SQL> !
/home/oracle > /etc/init.d/oracleasm listdisks
T1_ASM01
T1_ASM02
T1_ASM03
T1_ASM04
T1_ASM05
T2_BACKUP01
/home/oracle >

View 1 Replies View Related

SQL & PL/SQL :: Adding TimeStamp Values In Table

Apr 4, 2011

I want to have sum of Time Stamp Values in a Table. i.e. Group by Query

example : Select Name, Sum(Timestamp column) from Emp group by name;

OR

I have Time values in character column of a table. i.e. Table TT column t1 char(5) values '03:02'

Above mentioned values in more than one line, i want to get the sum of all the values and it should be a time value.

View 7 Replies View Related

SQL & PL/SQL :: Adding Conditions In CASE Statement?

Oct 28, 2010

I am trying to use a CASE statement

CASE WHEN (EP.ORDER_NUMBER IS NOT NULL AND ATD.IS_DISCONNECT_CREDIT = 1 ) THEN
.........
......
END

In my case when I club two conditions after WHEN in case statement , everytime the first condtion is satisfied (i.e EP.ORDER_NUMBER IS NOT NULL) it is entering into the loop.

Irrespective of using AND or OR after the first condition I am getting the same results.

I want to enter the CASE statement only when both the conditions (1st and 2nd )are satisfied

View 10 Replies View Related

SQL & PL/SQL :: Adding Grand Total In Result

Jun 21, 2010

i just want to add at the end of each area_cd the total number of asset.. what do you think i should add in my query????

View 32 Replies View Related

SQL & PL/SQL :: Adding Time Zone Onto A Query

Nov 17, 2011

I was given this query: SELECT TZ_OFFSET('EST'),dbTIMEZONE,SESSIONTIMEZONE, CURRENT_TIMESTAMP FROM DUAL;

My coworker also said this:

Using this statement as a starting point:

SELECT TZ_OFFSET('EST'),dbTIMEZONE,SESSIONTIMEZONE, CURRENT_TIMESTAMP FROM DUAL;

but I need

for

select -5 from dual;

to return

America/NewYork or EST

View 6 Replies View Related

SQL & PL/SQL :: Adding Inner-query Select To Group By?

Aug 30, 2011

I have this query

select EAG.AUDIT_NUMBER Audit_Nbr,
EAG.AUDITEE_NAME Grantee_Name ,
EAG.EIN Grantee_EIN_IRS,
EAG.AUDIT_ISSUE_DATE Audit_Issue_Date,
MAX(AUDT.derive_audit_progress_status(EAG.SYS_AUDIT_ID )) Audit_Clesed_Date,
EAG.OIG_DUE_DATE Six_Month_Due_Date,

[code].....

I want o add additional column to this

I added this sql

SELECT CASE
WHEN currentstep.step_id IN (100)
THEN currentstep.start_date
ELSE (SELECT start_date
FROM audt.os_historystep
WHERE ID =

[code].....

here is the completed query

select EAG.AUDIT_NUMBER Audit_Nbr,
(
SELECT CASE
WHEN currentstep.step_id IN (100)
THEN currentstep.start_date
ELSE (SELECT start_date
FROM audt.os_historystep

[code].....

when I try select from this query I get ORA-00904: "DATE1": invalid identifier.

how to add the new column in group by clause.

View 6 Replies View Related

SQL & PL/SQL :: Get A Error While Adding Data Through Form

Oct 12, 2010

I get a error while adding data thru form...

Error no ORA-04098 ( trigger name is invalid and failed re-validation)

i CREATED TRIGGER ON THAT TABLE

Trigger Code is :
CREATE OR REPLACE TRIGGER TEST0_TRG
after insert on TEST0 REFERENCING
NEW AS NEW OLD AS OLD FOR EACH ROW
BEGIN
[code]......

View 4 Replies View Related







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