Displaying the row number
I am having the data as like below(sample data)
Col1 Col2
A AA
A BB
A CC
B BA
B BB
C CA
D DA
D DB
E EA
E EB
I want to show the seq number as a third column as like below. (seq number is with respect to Col1)
Col1 Col2 num
A AA 1
A BB 1
A CC 1
B BA 2
B BB 2
C CA 3
D DA 4
D DB 4
E EA 5
E EB 5
Thanks in Advance,
Bala
Hi,
Try this
WITH T AS (
SELECT 'A' AS COL1, 'AA' AS COL2 FROM DUAL UNION ALL
SELECT 'A','BB' FROM DUAL UNION ALL
SELECT 'A','CC' FROM DUAL UNION ALL
SELECT 'B','BA' FROM DUAL UNION ALL
SELECT 'B','BB' FROM DUAL UNION ALL
SELECT 'C','CA' FROM DUAL UNION ALL
SELECT 'D','DA' FROM DUAL UNION ALL
SELECT 'D','DB' FROM DUAL UNION ALL
SELECT 'E','EA' FROM DUAL UNION ALL
SELECT 'E','EB' FROM DUAL)
SELECT COL1, COL2, RANK() OVER (partition by col1 order by col2) FROM Tor
WITH T AS (
SELECT 'A' AS COL1, 'AA' AS COL2 FROM DUAL UNION ALL
SELECT 'A','BB' FROM DUAL UNION ALL
SELECT 'A','CC' FROM DUAL UNION ALL
SELECT 'B','BA' FROM DUAL UNION ALL
SELECT 'B','BB' FROM DUAL UNION ALL
SELECT 'C','CA' FROM DUAL UNION ALL
SELECT 'D','DA' FROM DUAL UNION ALL
SELECT 'D','DB' FROM DUAL UNION ALL
SELECT 'E','EA' FROM DUAL UNION ALL
SELECT 'E','EB' FROM DUAL)
SELECT COL1, COL2, dense_RANK() OVER (order by col1) FROM T@peter - apologies for replying to your post
cheers
VT
Edited by: VT on Jan 27, 2011 7:47 PM
Similar Messages
-
How to display the rows number of times by giving the column values?
Hi All,
I want to display the rows number of times as the value exists in num column in the below query
with t AS
( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
UNION ALL
SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
UNION ALL
SELECT 'krishna' NAME, 'hyd' LOC, 1 NUM FROM DUAL )
SELECT T.* FROM T
CONNECT BY ROWNUM <= NUM
Expected output:
venkatesh hyd 2
venkatesh hyd 2
prasad hyd 3
prasad hyd 3
prasad hyd 3
krishna hyd 1Edited by: Nag Aswadhati on Nov 1, 2012 12:34 AMNag Aswadhati wrote:
Hi All,
I want to display the rows number of times as the value exists in num column in the below query
Expected output:
venkatesh hyd 2
venkatesh hyd 2
prasad hyd 3
prasad hyd 3
prasad hyd 3
krishna hyd 1Using Connect By:-
with t AS
( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
UNION ALL
SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
UNION ALL
select 'krishna' name, 'hyd' loc, 1 num from dual )
select t.name, t.loc
from t
connect by level <= num
and name = prior name
and (prior sys_guid() is not null);
NAME LOC
krishna hyd
prasad hyd
prasad hyd
prasad hyd
venkatesh hyd
venkatesh hyd
6 rows selected -
Display Line/Row number in Grid
Hi,
How to display the row number (1,2,3...) in a grid?
Should I go only by changing the query?
Or is there any SDK supported way of doing that?
Please help me with this information.
Thanks.
GeethaHi Geetha,
didn't have time to answer your earlier ...
you are looking for something like
SELECT (SELECT COUNT(*)
FROM OCRD T2
WHERE T2.CardCode <= T1.CardCode) as RowIndex, T1.*
FROM OCRD T1
ORDER BY RowIndex
this sample will display a row number of the complete ocrd table -
Display the total number of rows for the report in OBIEE 11g
Hi, In obiee 11g, the pagination will be 1-25. Is there any possiblity in obiee to show the total rows count next to pagination. Ex: if the result contains 120 rows. it should display after the pagination
Records 1-25. Total of Records : 120
Is there any way we can display the total number of rows for the report.
Kindly help me.. Its very urgent requirement.
MAny Thank in advacneCheck this http://obiee100.blogspot.com/2011/07/display-total-number-of-records-in.html
and
http://docs.oracle.com/cd/E28280_01/bi.1111/e10544/appsql.htm#CHDCDIDA
You have to go something like as suggested in previous link.
Mark as correct/helpful -
How can I get the row number of display automatically on a table?
I have a table of measurements, and I would like the row number to be displayed on each row. The challenge is that each time I run the program, the total number of rows will be different, so I would like the numbers to update every time I run the program based on the current number of rows.
I have attached a picture to illustrate what I am trying to do.
Solved!
Go to Solution.
Attachments:
picture of table.JPG 70 KBFind the attached example (saved in version 2009), and you can extract what you need for your code...!!
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT.
Attachments:
Example (Enter Row Header).vi 12 KB -
How can I display the rows into columns.
How can I display the rows into columns. I mean
Create table STYLE_M
(Master varchar2(10), child varchar2(10));
Insert itno style_m
('MASTER1','CHILD1');
Insert itno style_m
('MASTER2','CHILD1');
Insert itno style_m
('MASTER2','CHILD2');
Insert itno style_m
('MASTER3','CHILD1');
Insert itno style_m
('MASTER3','CHILD2');
Insert itno style_m
('MASTER3','CHILD3');
Note : The Master may have any number of childs.
I want to display like this..
Master child1, child2, child3, .......(dynamic)
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3
Sorry for disturbing you. Please hlp me out if you have any slution.
Thanks alot.
Ram DontineniHere's a straight SQL "non-dynamic" approach.
This would be used if you knew the amount of children.
SELECT
master,
MAX(DECODE(r, 1, child, NULL)) || ' ' || MAX(DECODE(r, 2, child, NULL)) || ' ' || MAX(DECODE(r, 3, child, NULL)) children
FROM
SELECT
master,
child,
ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r
FROM
style_m
GROUP BY
master
MASTER CHILDREN
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3 Since you said that the number of children can vary, I incorporated the same logic into a dynamic query.
SET AUTOPRINT ON
VAR x REFCURSOR
DECLARE
v_sql VARCHAR2(1000) := 'SELECT master, ';
v_group_by VARCHAR2(200) := 'FROM (SELECT master, child, ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r FROM style_m) GROUP BY master';
v_count PLS_INTEGER;
BEGIN
SELECT
MAX(COUNT(*))
INTO v_count
FROM
style_m
GROUP BY
master;
FOR i IN 1..v_count
LOOP
v_sql := v_sql || 'MAX(DECODE(r, ' || i || ', child, NULL))' || ' || '' '' || ';
END LOOP;
v_sql := RTRIM(v_sql, ' || '' '' ||') ||' children ' || v_group_by;
OPEN :x FOR v_sql;
END;
PL/SQL procedure successfully completed.
MASTER CHILDREN
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3I'll point your other thread to this one. -
Report for displaying the order number & order date..
HI ALL,
can any body help me for displaying the order number,customer name,material name & order date..in report
i dnt know the which are the table i need to use...
can anybody tell me which are table do i need to use and fields in tables
input to report from the user are cutomer number,purchase order numbervendor number & sales number
waiting for positive reply form u people.....
thanks
Zabeerulla
Moderator message: "spec dumping", please work yourself first on your requirement, do some research, talk to a functional consultant near you.
Edited by: Thomas Zloch on Feb 28, 2011 2:14 PMThx dharma raj ...
problem is ,input to report from the user are cutomer number,purchase order number,vendor number & sales number
report should contain
customer name
order date
order #
vendor name
material name
can u please tell me which are the table do i need to use...
i have ,please look into it...let me know if am incorrect
customer name -> kna1_name where kna1_kunnr=knagv_kunnr
order date -> vbak_audat
order nunber->vbak_vbeln
vendor name -> LFA1_NAME where LFA1_LIFNR=MEPO_TOPLINE(superfileld)
material # -> VBAP_ARKTX where VBAP_VBELN=VBAK_VBELN
HELP ME OUT...
THX
ZABEER -
TO Display the row data as column in ALV
Hi experts ,
Need to display the row data in ALV as column.
The column of an ALV has the fieldnames of a table , this needs to be displayed as row data , that is as single row.
How can this can be achieved?Hi,
Actually it is not possible to disaply in multiple lines.
https://www.sdn.sap.com/sdn/collaboration.sdn?contenttype=url&content=https%3A//forums.sdn.sap.com/thread.jspa%3FforumID%3D50%26threadID%3D49517%26messageID%3D506378%23506378
https://www.sdn.sap.com/sdn/collaboration.sdn?contenttype=url&content=https%3A//forums.sdn.sap.com/thread.jspa%3FforumID%3D50%26threadID%3D41133%26messageID%3D403371%23403371
This problem was discussed many times in this forum, u can search for more results. -
in the old version at the bottom of the sceen it displayed the total number of media and the size of the files. how can i get the new version to diplay this?
You're welcome. It was frustrating for me as well until I stumbled across "the fix"
-
Hi list,
does any one know how I can get the row number the same as what I have in column rowno?
thanks
Arvin
REATE TABLE dbo.temptable
( y int NOT NULL,
e int not null,
c int not null,
rowno int not null)
/* insert values */
INSERT INTO dbo.temptable(y,e,c,rowno ) VALUES
(1,1,1,1),
(1,1,2,1),
(1,1,3,1),
(1,20,1,2),
(1,20,2,2),
(1,20,3,2),
(1,3,1,3),
(1,3,1,3),
(2,1,1,1),
(2,1,1,1),
(2,2,1,2),
(2,2,1,2);You may update your rownumber column with Column "e".
But why do you duplicate your data? May be there is no particular reason, you may be wasting space for it
Try the below:
CREATE TABLE dbo.temptable
( y int NOT NULL,
e int not null,
c int not null,
ronum int null)
INSERT INTO dbo.temptable(y,e,c ) VALUES
(1,1,1),
(1,1,2),
(1,1,3),
(1,20,1),
(1,20,2)
select * from temptable
update dbo.temptable Set ronum=e
Select * From dbo.temptable
DRop table dbo.temptable -
Calculating the row number with DAX
Hello,
Can somebody help me to obtain the row number in a calculated column using DAX (PowerPivot 2013) ?
I do not have any column that would contain unique values (would be easy in that case !). I just want to obtain a different value in each row.
Thank you.Hi DP17000,
According to your description, you need to add a column with the RowNumber to your Pivot table by using DAX, right?
Based on my tested, we can use a ranks function to achieve your requirement.
=RANKX(case0305,[amount],[amount],0,dense)
Reference
https://msdn.microsoft.com/en-us/library/gg492185.aspx?f=255&MSPPError=-2147217396
http://ayadshammout.com/2013/02/19/dax-rankx-function-scenarios/
Regards,
Charlie Liao
TechNet Community Support -
I'm using qurey panel with table.i want to display the rows as default
Hi
I'm using jdeveloper 11.1.1.2.0 with ADF 11g.
I'm using qurey panel with table , for first time when i run ,rows are not displayed as default .After i fire search button records / rows are displaying.Now i want to display the rows in table when i run for first time , mean i want to display rows by default.
thanks in advance.Hi,
if the queryPanel is based on a ViewCriteria in ADF BC then this autoExecute can be defined on the VC definition
Frank -
TableView -- get the row number of the top most current visible row
Is there any way to get the row number of the top most visible row, and or bottom most visible row in TableView?
If you already know the document's name, the sheet's name and the table's name, the easy way is :
--Here you may replace the three values by the current ones
set dName to 1
set sName to 1
set tName to 1
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
tell first cell of the selection range to set {rowNum1, columnNum1} to {address of its row, address of its column}
tell last cell of the selection range to set {rowNum2, columnNum2} to {address of its row, address of its column}
end tell
Yvan KOENIG (VALLAURIS, France) mercredi 9 février 2011 17:22:21 -
Retrieving the row number where a certain value exists
Hi,
I wanted to find out if there is a way to retrieve the row number of a row where a certain value exists. For example, if I had a query
Create or replace Procedure p1
IS
v_Stmt varchar2(100);
BEGIN
v_Stmt := 'Select * from emp where lname = 'Davis'';
Execute Immediate v_Stmt;
END;
SQL> exec p1;
Then, I would like to find out that this name is on row 3.
Can anyone tell me how this can be done?
Thanks in advance.
Sincerely,
Nikhil Kulkarnitheres is no rownum related to a particular row. A rownum is a pseudocolumn which value may be different for the same row depending on the query you do. What you can use is the rowid which is the row's address.
HTH
Maurice -
About the row number of the datagrid[Flex 2.0 beta3]
I want to add a column to the datagrid,which will indicates
the row number.Who can tell me how to do it?
And how to keep the number's sequence unchanged when the
header of one of other columns is cliked to sort the
data?If I understand this correctly. Then would it not make more
sense to say in
the LiveDocs --
makeObjectsBindable - After the remote call (RPC, HTTP, SOAP,
etc) returns
its value. Flex tries to automatically convert the result
into an
ArrayCollection (if it looks like an array, even if it was
XML) [Or
others???] format. This automatic conversion controlled by
the
makeObjectBindable property. If false, Flex does not attempt
the conversion
and the result will be in (xml?) format.
"peterent" <[email protected]> wrote in
message
news:eali1i$1q9$[email protected]..
> Results that come back which look like Arrays will be
turned into
> ArrayCollections automatically. Since most people
immediate turn an Array
> into
> an ArrayCollection, we went ahead and did it for you.
Try getting rid of
> your
> new ArrayCollection in the result handler.
>
Maybe you are looking for
-
Downloading fields from a View to a file
Hi, I want to download certain fields from a View to a file. Is there an example on SDN which shows how this can be done or is there any way to do this? Thanks & Regards, Yogeshwari Agashe.
-
How to extract the senders IP address of an email?
How to extract the senders IP adress of an email using applescript ??
-
How to upload a binary file with Firefox 7
Don't know if this is the right forum to ask this - if not, please point me in the right direction. I am an embedded developer using Firefox as the user interface to an embedded web server. In the past I've been using file.getAsBinary() to read the l
-
I have a project with 4 short movies. The project seems to burn fine but during my longest movie (38 min) the sound drops out of the last 5 minutes. These movies were created by FCP. I was able to manage a DVD Studio Pro version (which is not working
-
This is what I'd like to achieve. Thanks in advance. Status of Decision Point in PPM of the Portfolio Item updated to "QA Clear" when the Product Specification is "Retail-Ready."