SQL & PL/SQL :: Row Number Grouped By

Oct 18, 2010

I have a sql like this

SELECT RO_NO, HANDLED_BY
FROM MSS_VEH_INPUT
GROUP BY HANDLED_BY, RO_NO

I want the output like this with row num grouped by handled_by,ro_no

SNO HANDLED_BY RO_NO
1 KUMAR 12
2 KUMAR 13
3 KUMAR 14
1 LEE 15
2 LEE 16
1 MARVIN 17
2 MARVIN 18

So from this I can know Kumar how many ro,lee how many ro and marvin ro.?

View 6 Replies


ADVERTISEMENT

SQL & PL/SQL :: Dynamically Concatenating Column Values Based Upon Number Of Grouped Columns

Feb 17, 2011

My requirement is to concatenate two column values and place them in a new column.I have done it using self join but it limits the purpose,meaning when I have more than 2 values for grouped columns then it won't work.How to make this dynamic,so that for any number of columns grouped,I can concatenate.

SELECT a.co_nm, a.mnfst_nr, a.mnfst_qty,
a.mnfst_nr || ':' || a.mnfst_qty || ';' || b.mnfst_nr || ':'
|| b.mnfst_qty
FROM vw_acao_critical a JOIN vw_acao_critical b
ON a.co_nm = b.co_nm AND a.mnfst_nr = b.mnfst_nr
[code]......

What will be the case when I need to concatenate for more number of values.

like when co_nm has three bahs and manfst_nr and manfst_qty has 3 values for each for bah.and if three are having same_mnfst nr then I should use something dynamic.how to achieve this.

View 10 Replies View Related

Unable To Send Grouped Value To Subquery

Mar 9, 2010

resolving this problem the query is

SELECT DAY_NBR ||' '||HOUR_NBR ||' '||MINUTE_NBR AS "@TIMEPOINT",
RTRIM ( xmlagg (xmlelement (c, procedure_nm || ', ')).extract ('//text()'), ', ' ) AS "@LABEL",
RTRIM ( xmlagg (xmlelement (c, procedure_id || ', ')).extract ('//text()'), ', ' ) AS "@PROCEDURE_ID",
cursor
(SELECT SUBJECT_NBR AS "@LABEL",TO_CHAR (PSUB.procedure_tm,'HH24:MI') AS "@TIME",
PROCEDURE_ID AS "@PROCEDURE_ID", PROCEDURE_SUB_ID AS "@PROCEDURE_SUB_ID"
FROM PROCEDURE_SUBJECT_TIME PSUB WHERE PSUB.ACTIVE_FLG = 1
AND PSUB.PROCEDURE_ID in pr.PROCEDURE_ID
ORDER BY PSUB.procedure_tm,PROCEDURE_ID
)AS VOLUNTEER
FROM SCHEDULE_PROCEDURE PR
WHERE active_flg = 1 and SCHEDULE_ID = 200900195269 group BY day_nbr,hour_nbr,minute_nbr,procedure_nm;

and the error getting is ORA-00979: not a GROUP BY expression

View 2 Replies View Related

SQL & PL/SQL :: Show Grouped Data - Extract Subsets In Same Query

Sep 5, 2013

the point is that I have a table with two columns and I am trying to find and easy way to show grouped data.

CREATE TABLE TEST_DATA(C1 VARCHAR2(1), C2 VARCHAR2(2));

INSERT INTO TEST_DATA VALUES('1','A1');
INSERT INTO TEST_DATA VALUES('1','A2');
INSERT INTO TEST_DATA VALUES('1','A3');

[Code] .....

With the sample data there are 4 groups based in c1 column:

1 : A1,A2,A3
2 : A1,A2,A4
3 : A1,A2,A3
4 : A1,A2,A4
5 : A6,A7

I'm trying to get and output like :

A1,A2,A3 : 1,3
A1,A2,A4 : 2,4

I was trying something like :

select t1.c1 as gr1, t2.c1 as gr2, t1.c2
from test_data t1,test_data t2
where t1.c1<>t2.c1 and t1.c2=t2.c2
and
(select count(*) from test_data t3 where t3.c1=t1.c1)=
(select count(*) from test_data t4 where t4.c1=t2.c1)
order by 1 asc, 2 asc

but I don't find the way to refilter to group the data as expected. The idea is find subsets and show the set of data and values in column c1.

View 4 Replies View Related

PL/SQL :: Query To Be Displayed Grouped By Year / Month And Then By Assignment?

May 27, 2013

I have the following table structure with values

CREATE TABLE DUMMY
  (
    SR_NUMBER          VARCHAR2(100 CHAR),
    ASSIGNMENT_GROUP   VARCHAR2(100 CHAR),
    REASSIGNMENT_COUNT VARCHAR2(100 CHAR),
    CREATED DATE,

[code]...

?I have the following requirement, the output should be:

Ticket count (sr_number)
% of tickets inside DL
Number of tickets inside DL
Average cycle time (cycle time = closed date - created date)
Total cycle time (cycle time = closed date - created date)
Number of reassignments (sum)

DL - (deadline) formula is, closed date <= target_date

This should be displayed, grouped by year, then month and then by assignment group. The values should be in descending order(dates) Not sure how group by will work here.I am able to write the basic code for the above, but group by based on year, month and assignment group is pretty confusing to me.

View 10 Replies View Related

Get Count Of Records Grouped By Another Field From Transactions Table

Nov 5, 2009

I have a table that cannot be changed with a field called transaction_reference in the transactions table. This field contains any number of some values in a look-up table called codes.

The table codes contains 'AA', 'BB', 'CC'.

A typical transaction_reference field may look like 'CC BB' or 'AA' or 'AA CC' or 'AA CC BB' - any number, any order.My goal is to get a count of records grouped by another field from the transactions table.

Transactions table example:
transaction_id | transaction_reference | family
---------------------------------------------
1 | AA BB | foo
2 | BB CC | bar
3 | BB | hello
4 | AA CC BB | foo
5 | BB AA | bar

So the results should look like:

family | code | count
foo | AA | 2
foo | BB | 2
foo | CC | 1
bar | AA | 1
bar | BB | 2
bar | CC | 1
hello | AA | 0
hello | BB | 1
hello | CC | 0

If the counts of 0 (like the third to last and last line above) don't show up I'm ok with that.I put together an explode function like this one here but I'm really not sure where to go from here. I can split the transaction_reference, but I'm not sure what to compare it to or how.

I realize that a field in the transactions table for AA, BB, and CC would be ideal, but I can't do that... the powers that be won't let me change the table.

for each exploded segment from transaction_reference
look for it in the codes table
if it exists, add 1 to the count

View 7 Replies View Related

PL/SQL :: Create View Which Is Aggregate Count Of Member Records / Grouped By Business_unit / Gender / Age Per Year

Oct 13, 2012

Using Oracle 11g...We have a table in our database of data with the following information:

MASTER_RECORD,
MEMBER_RECORD,
BUSINESS_UNIT,
GENDER,
DOB (date),
age [at time of month_record],
MONTH_RECORD (date) [31-MON-YEAR for recorded active month]

The table has ~55 million records. Existing index is only on MASTER_RECORD.There is now a need to create a view which is an aggregate count of member records, grouped by business_unit,gender, age per year. eg:

business_unit, gender, age, month_record, num_of_members -> for every combination
unit5, F, 25, 31-JUN-2011, 622
unit3, M, 18, 31-MAY-2011, 573

The view can be created now, but, is not fast enough to be reasonably considered a view. This table is re-created every month from a procedure, so there is flexibility on how it is created. Use interval partitioning by year( something I have not experienced using), create an index on the month_record,then create view.

View 2 Replies View Related

List Products List Of Client Grouped By Type Of Product?

Dec 14, 2011

Im trying to list the products list of a client grouped by type of the product. Ex:

product type

prod.A acid
prod.B flavour
prod.C acid
prod.D cleaner
prod.E flavour

I want to list something as:

Acid

Prod.A
Prod.C

Cleaner

prod.D

Flavour

prod.B
prod.E

View 1 Replies View Related

Reports & Discoverer :: How To Find Page Number And Total Number Of Pages

Jan 26, 2010

i am using oracle developer 6i report builder i required this type of query

example

if (:page number LIKE '1')
then
srw.set_text_color('darkred');
end if;

return (TRUE);
end;

but page number is not my table database item how can i use builtan page &<pagenumber> use for conditional format.

View 34 Replies View Related

SQL & PL/SQL :: Replacing 4 Digit Number In A Given String With The Same Number Incremented By 10000?

Jun 17, 2010

i want to replace 4 digit number in a given string with the same number incremented by 10000.

That mean in the given sting 1201 should be replace by 11201 (Icremented BY 10000).

Input String:

<query><matchAll>true</matchAll><row><columnId>1201</columnId><dataType>31</dataType><op>Like</op><val>North America - Houston</val></row><row><columnId>1212</columnId><dataType>31</dataType><op>!=</op><val>Agreement Date Mismatch</val></row><row><columnId>1212</columnId><dataType>31</dataType><op>!=</op><val>Facility Type Mismatch</val></row><row><columnId>1224</columnId><dataType>31</dataType><op>Like</op><val>y</val></row></query>

Required output :

<query><matchAll>true</matchAll><row><columnId>11201</columnId><dataType>31</dataType><op>Like</op><val>North America - Houston</val></row><row><columnId>11212</columnId><dataType>31</dataType><op>!=</op><val>Agreement Date Mismatch</val></row><row><columnId>11212</columnId><dataType>31</dataType><op>!=</op><val>Facility Type Mismatch</val></row><row><columnId>11224</columnId><dataType>31</dataType><op>Like</op><val>y</val></row></query>

View 7 Replies View Related

SQL & PL/SQL :: Extract Number And Previous Character From Where 5 Digit Number Starting

Oct 21, 2011

I have a text field and if the text field has 5 consecutive numbers then I have to extract the number and the previous character from where the 5digit number starting

For example i/p asdfasfsdS251432dasdasd o/p should be S251432

View 10 Replies View Related

Express Edition (XE) :: Why Maximum Number Of Voting Disk Is Even Number (32)

Oct 3, 2013

I gone through many forums and found that the number of voting disks should be always in odd number. Then why the maximum number of voting disk is 32?

View 1 Replies View Related

SQL & PL/SQL :: Count A List Of Number Value And Find Maximum Number?

May 21, 2010

how do I count a list of number value eg 1,1,1,1,3,3,6,4 and find the one with maximum number which is 1

View 5 Replies View Related

SQL & PL/SQL :: How To Generate Number (not Sequence Number) In Query

Mar 9, 2011

I have the following select query that works perfectly fine. Returns 25 rows based on the descending order of the price.But, I want add one more expression to this list of columns in this query (apart from customer_id).

the expression should look like Cust-01 for the first customer from the below query all the way to Cust-25 for the last customer.But how can I can generate 01 to 25 in oracle?

select customer_id from
(select customer_id from capitalPLAN
where member_status = 'MEMBER' AND customer_id NOT in ('156','201','1385','2125','3906','165')
order by price desc
)
where rownum <= 25

View 4 Replies View Related

PL/SQL :: Insert Number Into Column With Type  NUMBER(10,0)

Sep 28, 2012

my column type is NUMBER(10,0) ,it accept the input value from text field I using TO_NUMBER(?) to insert value into table, is the a way to handle if the input is 'aaaaaaaaaa' not digit?

View 6 Replies View Related

SQL & PL/SQL :: Number Generation MINUS Number Used

Feb 19, 2011

Here is script of tables

Quote:drop table p;
create table p (qty number(3), beg_no number(5));
insert into p values(5, 110);
insert into p values(8, 786);

drop table s;

create table s (used_no number(5));
insert into s values(111);
insert into s values(113);
insert into s values(791);

Table p: it has ticket quantity and ticket begining number. Thus according to first record ticket number will begin at 110 and will end at 110+5 (Beg_no +qty). According to second record ticket number will begin at 786 and will end at 786+8 (Beg_no +qty). This table can have many records.

Table s: it has ticket numbers which are sold. The ticket will always be any number from table and will lay in any record in this format between beg_no and beg_no+qty

Required: I want "p MINUS s" information. i.e.

Quote:
110
112
114
786
787
788
789
790
792
793

I am not expert in level by command.

Oracle version: 9
OS: Windows XP

View 3 Replies View Related

Reports & Discoverer :: How To Compare Current Page Number With Total Page Number

Feb 19, 2013

I have a report created in Reports6i. I have two fields at the bottom

1.Page Total
2.Voucher Total

I do not want to print the Page Total if the total number of pages = 1.

How can I achieve this?

View 1 Replies View Related

SQL & PL/SQL :: Add Number Containing (,)?

Apr 19, 2010

i have field(column name ) amata type is number . in excel i am having "," in amount field eg 9,999. how to do it

View 6 Replies View Related

SQL & PL/SQL :: How To Get Serial Number

Mar 12, 2013

I have following table.

CREATE TABLE ABC
(
DPT_NUM NUMBER,
LOT_NUM NUMBER,
ASSOCIATED_WITH_LOT NUMBER
);
SET DEFINE OFF;
Insert into ABC
[code]......

Now i run follwoing query and result is

select * from abc
DPT_NUMLOT_NUMASSOCIATED_WITH_LOT

1501
1502501
1509501
1511
1503
1516
1522
1565
1569565
2601
2602
2604602
2607
2508

I need following result

DPT_NUMLOT_NUMASSOCIATED_WITH_LOT Serial_Number

1501 1
1502501 2
1509501 2
1511 3
1503 4
1516 1
1522 2
1565 3
1569565 3
2601 1
2602 2
2604602 2
2607 3
2508 3

Note that serial number must reset after each 4 lot_num againt dpt_num. Not that where lot is associated in associated_with_lot there serial number must be same as serial number is for associated lot.

View 7 Replies View Related

SQL & PL/SQL :: How To Convert RAW To Number

Sep 27, 2013

can we convert RAW to number in sql.because i have to bitand of one raw and number variable.

View 3 Replies View Related

SQL & PL/SQL :: Reset Row Number

Mar 1, 2013

I have Follwoing Table and data.

CREATE TABLE ABC(DPT_NUM NUMBER,LOT_NUM NUMBER);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 501, 1);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 502, 2);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 509, 3);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 511, 4);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 503, 5);

[Code]...

I write Following query.

SELECT DPT_NUM,LOT_NUM,ROW_NUMBER() OVER(PARTITION BY DPT_NUM ORDER BY DPT_NUM) SRL_NUM FROM ABC;

Result is

DPT_NUMLOT_NUMSRL_NUM
15011
15022
15093
15114
15035
15166
15227
15698

[Code]...

But i want to reset rownum after each 4. Mean after serial number 4 , serail number must start from 1. I want to reset serial number after each 4 records (lot_num) against dpt_num;

View 7 Replies View Related

SQL & PL/SQL :: Number Conversion

Jan 4, 2013

I have a table datatype number (12,10) that I am reading out of. I am taking the value from this source table and inserting it into a destination table of datatype number (12,15).

I do not have the ability to alter the tables. How can i convert this number so i can insert. I am currently getting the error "ORA-01438: value larger than specified precision allowed for this column"

I am trying to use the to_number, but it not working. How can i format this number field so i can read it from source where i have number (12,10) and insert it successfully in a higher precision table of number(12,15)

View 1 Replies View Related

SQL & PL/SQL :: Number Of Occurrence

Oct 29, 2010

I'm trying to find a way to see if a value occurs more than once in a string. I just need to know "T/F", or "Y/N", etc.

The string will be comma delimited.

String: '1,2,3,1'
Ans: "T"

String: '1,2,3,4'
Ans: "N"

They do need to match exactly. for instance

String: '1,2,3,1a'
Ans: "N"

Using some code I found on this site, I coded this but I'm sure there's a better way. Is there??

--Check for Duplicate combination row values
BEGIN
--Query will split the string into individual pieces.
--Group the pieces to see if any 2 rows are the same
--If no rows are the same then "no_data_found" exception is thrown
SELECT 'T'
INTO vResult

[Code]...

View 10 Replies View Related

SQL & PL/SQL :: How To Know Previous Scn Number

Jun 4, 2012

i want to know the all scn number's that are generated yesterday or in any previous day? how can i achieve it?

View 5 Replies View Related

PL/SQL :: Convert Number?

Jun 14, 2013

would need to convert a number in this way:10.1 ---> 10101.90 ----> 190  How can i?

View 1 Replies View Related

Sequence Number In 11g RAC

Sep 17, 2012

In our production, we have two nodes in the cluster. We use the sequence for one of the main table for primary key. Our application is expecting sequence number increments along with created date time stamp. Right now sequences are cached for each node and it creates problem for the application. We would not like to use NOCACHE option because it causes performance issue.

This is the current scenario -

Transaction #1 on Node 1 - Seq ID 1 - Time Stamp 12:01
Transaction #2 on Node 2 - Seq ID 51 - Time Stamp 12:02
Transaction #3 on Node 1 - Seq ID 2 - Time Stamp 12:03

When I try to query based on the time stamp, primary should also go up. To be very clear on what I would like to have, please consider the following example.Without using NOCACHE option, I need to have the data in the following order.

Transaction #1 on Node 1 - Seq ID 1 - Time Stamp 12:01
Transaction #2 on Node 2 - Seq ID 2 - Time Stamp 12:02
Transaction #3 on Node 1 - Seq ID 3 - Time Stamp 12:03

In other words, sequence number should always increment along with the time.

View 2 Replies View Related

CSI Number For Individuals

Feb 11, 2013

Is it possible to get a CSI number for individuals ?

i would like to have access to Metalink documents and access to any patchset updates. I know Oracle database is available for free downloads, but the version available is 11.2.0.1, patchset update is available to paid customers having CSI#.

How to obtain a CSI#. i am willing to pay and get a valid registration as an individual and not as a company.

View 2 Replies View Related

Row Number In Oracle 11.2.0.1

Apr 26, 2011

I am using ROWNUM pseduo column in one of the queries after using partition clause (analytic function, not table partition). The query is working fine in oracle 9i(9.2.0.8) but the same query didn't work as expected in Oracle 11g.

Environment:
OS: UNIX AIX 5.3
DB: Oracle 11.2.0.1

Is there any difference in using ROWNUM in these versions?

View 3 Replies View Related

SQL & PL/SQL :: Invalid Number

Dec 3, 2012

select to_char(to_date(mcih_date, 'dd-mm-yyyy')),
mcih_terms from I_MEMO_CONF_H;
TO_CHAR(TO_DATE(MCIH_DATE,'DD-MCIH_TERMS
118-OCT-1245
206-NOV-1222

[Code]...

why i am getting this error?

View 3 Replies View Related

Job Number In Dba_jobs

Jun 20, 2012

Is there a way to manually assign a job number in dbms_job.submit? I tried these but did not worked

DECLARE
X SYS.DBA_JOBS.JOB%TYPE := 103;
BEGIN
SYS.DBMS_JOB.SUBMIT
( job => X
,what => 'precedure_name;'
[code].......,

It was successful but it was assigned to a different number.

View 6 Replies View Related







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