Necessary to valuate the sequence in another column in oracle
Hi all
I have the sql like query below
Select header_id, order_number of oe_order_headers_all.
and that's how the display of the data
heder_id order_number
111 500001
121 500400
I need to display a different field with values of sequence like as below
ID heder_id order_number
1 111 500001
2 121 500400
so, how to get the sequence value in another column help me please on this.
Thnaks
You can use virtual ROWNUM
Select rownum, header_id, order_number of oe_order_headers_all id
Tags: Database
Similar Questions
-
How do rotate on a date and see the sum of the value of another column
Hello
I searched through the forum and cannot find a query similar to my question feels so post this new thread.
First of all, it is probably useful indicating that I am using Oracle 10 g.
I have a table that is used to store the details of the booking (essentially a booking system) and I would use this data to display the details of the customers stay on one line.
The table has the following columns:
Some example records could be:BOOKING_ID CUSTOMER_ID DATE_OF_ARRIVAL NUMBER_OF_NIGHTS NUMBER_OF_PEOPLE
On this basis I would like to display the output so that I can show a sum of the NUMBER_OF_PEOPLE reserved to per customer per day, as such:BOOKING_ID CUSTOMER_ID DATE_OF_ARRIVAL NUMBER_OF_NIGHTS NUMBER_OF_PEOPLE -------------------------------------------------------------------------------------------- 1 201 13-JAN-2010 5 1 2 202 13-JAN-2010 3 2 3 202 13-JAN-2010 4 1 4 203 15-JAN-2010 2 3
I watched analytical functions in the documentation and several books of Oracle that I have, but have so far struggled to find how to make the performance desired. Even using the excellent response to the previous post on the forum, I got I was not able to get a feasible request.CUSTOMER_ID 13-JAN 14-JAN 15-JAN 16-JAN 17-JAN 18-JAN 19-JAN ----------------------------------------------------------------------------------------- 201 1 1 1 1 1 0 0 202 3 3 3 1 0 0 0 203 0 0 3 3 0 0 0
Any help or advice would be much appreciated.
Kind regards
Stu
Published by: macmanxie on January 10, 2011 21:16Hello
macmanxie wrote:
... The suggested approach goes only to return a number if the DATE_OF_ARRIVAL corresponds to the date in the CASE statement, however I have the added complexity of wanting to show a count of all the days that the customer is booked, for, by making use of the NUMBER_OF_NIGHTS. I tried to use some of the examples provided on morganslibrary.org, for example:sum( CASE WHEN TRUNC (arrival_date) between '01/13/2011' and TRUNC (arrival_date+no_of_nights) THEN nvl(no_of_people,0) ELSE 0 END) AS jan_13
but this does not produce the desired result.
You check if arrival_date is between January 13 and arrival_date + no_of_nights (as if the arrival date could all be posterior to the arrival_date + no_of_nights).
Are not really interested in whether or not January 13 ib between arrival_date and arrival_date + no_of_nights?NVL ( SUM ( CASE WHEN TO_DATE ( '01/13/2011' , 'MM/DD/YYYY' ) BETWEEN TRUNC (arrival_date) AND TRUNC (arrival_date) + no_of_nights THEN no_of_people END ) , 0 ) AS jan_13
Always format your code. It is important to format your code if you are the only who who will ever read but it is even more important if you are posting on a forum like this and ask other people to read.
Not to compare the DATEs in the strings; explicitly use a conversion function, like TO_DATE, above, where necessary.
Both
SUM (NVL (x, 0)) and
NVL (SUM (x), 0) get the same results, but the latter is more effective. If you have 1000 lines, the first way is calling NVL 1000 times, but the second way is calling only once.If your previous thread
Re: How to count the occurrence of a date in a range
Gets you the right data, but it has one row for each distinct combination of customer_id and date, then you can switch it to a form that contains a line by the customer and another column for each date.If you need help, post CREATE TABLE and INSERT statements for some examples of data and outcomes from these data. The post you are trying better to a request, including a subquery that gets no cross-the raw table dynamic results.
There will be a fixed number of columns in the output swing? If this is not the case, how do you deal with that? Which of these options in the thread I posted above)
Re: County report and the sum of the number of rows by multiple columns
) is best for your needs? Than others is acceptable? -
Sum according to the condition of another column
Hello
I develop a RTF to BI Publisher 11g, where the situation to make the amount based on the value in another column I
The sum of the column C amount what code = c
Total sum of D of the column amount what code = DDATE CODE total
Apr - 13 C 234
Apr - 13 C 234
Apr - 13 C 234
Apr - 13 D 100
Apr - 13 D 100
Apr - 13 D 100
Total C 702
Total D 300Please, let me know the formula or the workaround to achieve this.
Kind regards
AgnesNeed to see your xml structure to provide you with the exact code
Assuming that it is the structure:
Apr - 13 C
234 8 Apr - 13 C
234 0 After that you for each group pieces of code are the following:
Total C:
Total D:
Thank you
Bipuser
-
Add void partition on another column in oracle
I have a table that has two partitions (as standard): first_half and second_half, based on a column "INSERT_DAY."
I must add subpartitions 'SUCCESS' and 'SUCCESS' based on the values in another column 'STATUS' (subpartition by list) that I have to turn my score range on composite (range-list).
I don't want to drop the existing tables or partitions. What is the ALTER query for this?
PS: Is Oracle 9i database
Thanks for posting the actual code. This makes it much easier to see what is happening and test things.
The requirement is to remove all records with counter = 3 (which means successful load) for records that have more than 15 days.
Then you should just REMOVE the lines and do with it.
So I thought, why not create partitions of sub metered so that the final DDL would be something like the following.
Any change like this for the partitioning of the table means that all data should be transferred into a new segment.
Please explain how to move all THE data (including the data that you want to remove) is better than just delete the data.
I would then write a request for DELETION, which would take a long time to run.
What evidence do you have that a DELETION would "take some time" to run?
How many lines are there in the table? How many of these lines you want to delete?
-
Add column if the value in another column
How can I add a column as column name 'YES_OR_NO.
SELECT VALUE_ID IN THE TABLE TABLE_NAME
VALUE_ID
---
1
2
3
4
5
Now, I want to create another column in the sql query called YES_OR_NO and that if there is a value in VALUE_ID then column YES_OR_NO must say 'YES' if there is no value in the column VALUE_ID of this line YES_OR_NO must say 'NO '.
or just a way for her also to work would be to show this new column or not if a value in another column of table_name_2 (this would be ideal)
If new column yes_or_no and fill by a Yes or a no if a value is found in another tableAssuming that you are on a version that supports the CASE expression:
SELECT VALUE_ID , case when VALUE_ID is null then 'NO' else 'YES' end as YES_NO FROM TABLE_NAME
-
How to change the filter to the filter by another column - group calendar page 1
Any version of the Summit either 4.2 or 5.0 - windows 7 OS
I know it's a very simple question, but I can't understand this.
I want to change the filter on the group calendar page 1 of the default "Event status" below
The only code that I find is shown below.
I added my own selection list of the button with the following code bar
< tt > Select GroupName, group_id from EBA_CA_EMAIL_GROUPS ORDER BY GroupName < /tt >
But when I change the selection list from one option to the other that the calendar is not sorted by events that have particular GroupName. I tried to replace the code in the default selection list and it did not work. There must be another code, check the filter.
How can I add my own list of selection and filter calendar events based on that select list option is selected?
Richie V wrote:
Any version of the Summit either 4.2 or 5.0 - windows 7 OS
I know it's a very simple question, but I can't understand this.
I want to change the filter on the group calendar page 1 of the default "Event status" below
I added my own selection list of the button with the following code bar
Select GroupName, group_id from EBA_CA_EMAIL_GROUPS ORDER BY GroupName
But when I change the selection list from one option to the other that the calendar is not sorted by events that have particular GroupName.
Probably you meant 'filtered' rather than 'sort '?
I tried to replace the code in the default selection list and it did not work. There must be another code, check the filter.
In the Group APEX 5.0 calendar application, the filter is implemented in line 20 of the schedule area source query:
select e.event_id, case when et.display_color is not null then 'apex-cal-'|| (select lower(cp.color_name) from eba_ca_color_prefs cp where cp.bg_color = et.display_color) end css_class, e.event_name, case when e.display_time = 'N' then trunc(e.event_date_time) else e.event_date_time end event_date_time, to_char(e.event_date_time,v('APP_TIME_FORMAT')) disp_time, substr ( case when to_char(e.event_date_time,'MI') = '00' then ltrim(to_char(e.event_date_time,'HHam'),'0') else ltrim(to_char(e.event_date_time,'HH:MIam'),'0') end|| ' '||e.event_name,1,255) disp_col from EBA_ca_events e, EBA_ca_event_types et where (:P1_EVENT_TYPE = e.type_id or :P1_EVENT_TYPE is null) and e.type_id = et.type_id (+)
with P1_EVENT_TYPE being included in the property of the region and by using the action Elements of the Page to send dynamic update schedule to trigger a refresh of partial page in the calendar area.
How can I add my own list of selection and filter calendar events based on that select list option is selected?
1 create your filter as a copy the item P1_EVENT_TYPE item.
2. replace the LOV definition by the code you need.
3. Add the necessary filter predicate in the WHERE clause of the query source region.
4. Add the name of your filter element to the region of the Items property of the Page to send.
5. Add the name of your item to the Items property in the when section of action Dynamics to update the calendar .
-
Interactive report, change in color of the text based on the value in another column
I have a sample report at this url:
workspace: homeworld
username: test_report
password: test_report
APEX version 4.2.3 database 11 g release 2...
# Application: 202: IR TEST REPORTS
Page in question is #2 page
I have the setup of the report and you must make the following change...
I have 2 columns: Comm and bonus.
If the bonus > comm, I need to change the text color of the color of the Red bonus
If the bonus, comm, I need to change the text color of the bonus in green color
If the bonus = comm, I need to change the text color of the bonus to black color
I tried using the code with the select and am NOT wanting that, since he will be delivered with the data when they are downloaded in CSV or Excel... Had thought using the construction by highlighting, but that does not compare one column to another...
Thought a dynamic action, but not clear on HOW to do this, so any help would be appreciated...
Thank you
Tony Miller
Software LuvMuffin
Hello
I think that number with JavaScript conversion may not be good idea because it's difficult manipulating different digital formats.
Check your example on page 3.
I have added to the report query
CASE WHEN COALESCE(bonus,0) > COALESCE(comm,0) THEN 'red' WHEN COALESCE(bonus,0) < COALESCE(comm,0) THEN 'green' WHEN COALESCE(bonus,0) = COALESCE(comm,0) THEN '#333333' END as fcolor
Then I modify every column Expression HTML to be as
#EMPNO#
Kind regards
Jari -
Search for a similar string in the 2D array and displays the result with another column
Hello
One who can help, I have a chart 2D of txt file that have as many lines and 5 columns and I want to do a search and display the other results of the column.
For example.
Column 0 1 2 3 4
12345 qwer asdf 12qwe tjhrtyert
werr 23568 wef fgertge fsefff
If I manage to find 12345 and I want to display 12qwe, what should I do in labview? Help, please!
-
How to order a tree with the help of another column?
I want to order the nodes of the tree using the column POSITION.
How can I do this?
I tried to ORDER BY position in the tree of query design, but who gives a completely weird result for the hierarchy tree.
http://www.freeimagehosting.NET/uploads/7460540c52.gifuse the order siblings by clause in your query
order siblings by position_no
Baig,
http://baigsorcl.blogspot.com -
the row_number() value another column in the same table
Hi all
I have NODE_DETAILS which has following of table columns
MSLINK
NODE_ID
RNUM
I update RNUM with row_number() value in ordering the mslink. I tried after update statement
Update)
Select / * + bypass_ujvc * / rnum has, row_number() over (order of mslink) NODE_DETAILS rrnum
)
set a = rrnum
But he throws ORA-01732: non-legal data manipulation operation on this display error
How can I update row_number() rnum column?
Thank you
SujnanYou can use MERGE
SQL> create table node_details 2 (mslink number 3 ,node_id number 4 ,rnum number 5 ) 6 / Table created. SQL> SQL> insert into node_details 2 select -rownum, rownum, null 3 from all_objects 4 where rownum <= 5 5 / 5 rows created. SQL> SQL> select * 2 from node_details 3 ; MSLINK NODE_ID RNUM ---------- ---------- ---------- -1 1 -2 2 -3 3 -4 4 -5 5 SQL> SQL> merge into node_details n 2 using (select rowid rid,rnum a, row_number() over (order by mslink) rrnum from NODE_DETAILS) v 3 on (v.rid = n.rowid) 4 when matched then 5 update set rnum = rrnum 6 ; 5 rows merged. SQL> SQL> select * 2 from node_details 3 ; MSLINK NODE_ID RNUM ---------- ---------- ---------- -1 1 5 -2 2 4 -3 3 3 -4 4 2 -5 5 1 SQL> SQL>
-
Getting the value of a column based on the value of another column in a max group
Please let me know if there is a simple way to do it. I came up with a way, but it is terribly inefficient and it must work quickly.
GROUP_ID NO_REGISTRE READ_VALUE QUARTERLY
---------- ----------- ---------- -----------------------------
2 1 0.035 00:00:00.000000000 01/01/2015
2 0.035
3 1 1.11 14:50:32.943000000 14/07/2015
3 2 222 01/01/0001 13:36:47.017436000
3 223.11
So what I need is for all no_registre is NULL, I need the value of QUARTERLY for the QUARTERLY to the MAX (READ_VALUE) for this GROUP_ID (not counting the rows where the no_registre is NULL). So the result would look like this:
GROUP_ID NO_REGISTRE READ_VALUE QUARTERLY
---------- ----------- ---------- -----------------------------
2 1 0.035 00:00:00.000000000 01/01/2015
2 0.035 00:00:00.000000000 01/01/2015
3 1 1.11 14:50:32.943000000 14/07/2015
3 2 222 01/01/0001 13:36:47.017436000
3 223.11 13:36:47.017436000 01/01/01
Someone at - it ideas?
Or maybe:
-production of the sample data:
WITH t (GROUP_ID, no_registre, READ_VALUE, QUARTERLY)
AS LONG AS)
SELECT 2, 1, 0.035, TIMESTAMP ' 2015-1-1 00:00:00 ' FROM DUAL
UNION ALL SELECT 2, NULL, 0.035, THE DOUBLE NULL
UNION ALL SELECT 3, 1, 1.11, TIMESTAMP ' 2015-07-14 14:50:32 ' FROM DUAL
UNION ALL SELECT 3, 2, 222, TIMESTAMP ' 0001-1-1-13:36:47 ' FROM DUAL
UNION 3 SELECT ALL, NULL, 223.11, NULL FROM DUAL
)
--
-actual query:
--
Select group_id
no_registre
read_value
, last_value (quarterly) ignores NULL values over (partition by arrested by no_registre last read_value null, group_id) quarterly
t;
-
Convert the equivalent function stragg columns in oracle sql
Hello
Sorry I forgot my version of Oracle:
I searched on google but I have not found the solution.SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for 64-bit Windows: Version 10.2.0.3.0 - Production NLSRTL Version 10.2.0.3.0 - Production
I'm looking for a function equivalent to the SQL stragg discoverer.
Note: stragg function convert columns in lines.
Thank you
Published by: Salim champion 2010-01-29 08:32SELECT deptno, stragg ('-' || ename) FROM emp_test GROUP BY deptno; DEPTNO STRAGG_STR ---------- ------------------------------------------------------------ 10 -CLARK-KING-MILLER 20 -SMITH-FORD-ADAMS-SCOTT-JONES 30 -ALLEN-BLAKE-MARTIN-TURNER-JAMES-WARD 3 rows selected.
Hello Salim
This feature does not exist inside the discoverer.My suggestion would be to create a SQL function, then import it in Finder using the System Administration tool. Now, you will be able to pass the deptno to the function and the function returns a single string containing the concatenated names.
This isn't a function difficult to write and if you would like some help please let us know.
Best wishes
Michael -
How to get the last row and the sum of all columns in a query
Hello
is there a way to get the last record for a column and the sum of all the Archives to another column in the same query.
Best regards
You must set your needs correctly volunteers to help here...
Your data are not good enough to bring you a precise solution. Purpose, you do not have a column, which draws a distinction between the first and the last entry.
The solution becomes easy based on your design.
I introduced a grouping called 'id' column and a time column called 'time_of_insert' (only this way you can say with confidence that you can differentiate between the first and last (also a foolproof solution) - you can possibly use sequence (instead of date but if you say that you can insert two lines at the same time) ((and then likely sequence would be a better choice to differentiate instead of a timestamp field) etc...)
With your sample data, something like this can be done to get the desired results.
-----------------------------------------------------------------------------------------------------------------------
WITH dataset AS
(SELECT 1 id, 10 used, 8 remain, systimestamp + 1/24 time_of_insert FROM DUAL
UNION ALL
SELECT the 1 id, 1, 7, systimestamp + 2/24 FROM DUAL
UNION ALL
SELECT the id 1, 2, 5, systimestamp + 3/24 FROM DUAL
UNION ALL
SELECT 1 id, 1, 0, systimestamp + 4/24 FROM DUAL
UNION ALL
SELECT 1 id, 0, 0, systimestamp + 5/24 FROM DUAL
UNION ALL
SELECT the 1 id, 1, 4, systimestamp + 6/24 FROM DUAL)
SELECT *.
(SELECT SUM (used) ON sum_all)
FIRST_VALUE (stay)
COURSES (PARTITION BY id ORDER BY time_of_insert DESC)
last_row
Of THE dataset)
WHERE ROWNUM = 1;
Output:
------------------------
SUM_ALL LAST_ROW
------------------------------
15 4
See you soon,.
Manik.
-
Review of the show in two columns
Apex 3.2
I have a report and she 22 rows and 1 column.
For the moment, I shows the first 15 lines and then you must be paginated.
The report will not grow much, maybe to 30 rows.
Is there a way to display the first 15 lines in column 1 and the second in another column, side by side etc.
Gus
Well Yes, you're right, that's enough undistinct.
The following should work better:
with base as
(select shortdescr, no_lig - col * 16 no_lig, Col.
from (select gwh.shortdescr, rownum, floor(rownum / 16) col no_lig
to select (separate gwh.shortdescr
of udm_wh gwh, udm_lde lde
where lde.ldeid = gwh.ldeid
and lde.ldekey = 'MCDGBL')))
Select t1.shortdescr, t2.shortdescr
from (select * base where col = 0) t1.
(select * base where col = 1) t2
where t1.row_num = t2.row_num (+)
Greetings
Chris
-
Problem when I drag the sequence...
Hello!
I have the first cc pro.
When I drag the sequence in another sequence timeline-it is not has become a unit and all videos and audios is still exist as they are.
I tried to change any preferences and nothing works...
What can I do now?
Thank you!
You do what is called "nesting".
In CC, there is an icon at the left end of the timeline that will show your elementary or nested sequence.
Maybe you are looking for
-
Why on SIM Manager is showing the same number of SIM 1 and SIM 2?
I recently purchased Intex FX Cloud and inserted two different operator SIM cards. But the phone showing the same number (SIM 2) for both SIMS (SIM 1 and SIM 2). I have already reset the device, but that did not help. I would like to know how to fix
-
Fix valid security or phishing?
Last night (5/14) when I stopped my XP computer I got the shield of security code and the message not to shut down the computer as it would thus automatically after updates have been installed. Since it was assumed no updates for XP any more I was af
-
the backup Cloud preventing defragmentation can anyone help please?
Using know-how cloud (wish I had never started it!) Now when I try to defrag computer it stops and tells me:-paused for volume shadow copy? I use XP - can anyone help please?
-
Printer Wizard opens in the e Word HP OfficeJet Pro Premium N911n pad
Windows 7 64 bit system HP Officejet pro 8600 premium e-all-in-one printer N911n Ser CN1BF1R2KZ uninstalled and re installed but the "assistant" opens in "Word pad" instead of the typical Wizard. I tried updates etc., but still do not get to Wizard
-
Dialer after Froyo 2.2.1 - numbers 1 &; 2 do not work
Did someone had the problem where they try to dial a number, but every time they touch the 1 or the 2 on the keyboard of the Dialer phone will not register the number as being pressed? Has anyone else had the problem where they called a number and th