Combine the ORDER BY sorting columns?
Hello-I wonder if this is possible:
I would like to combine two columns of Dates (from separate tables) so that the SELECT result can be sorted (ORDER BY) based on the order of these TWO dates, not just one or the other.
Wherever a date exists in a column, the other column contains a null entry. For example:
ID-date1 - date2.
0 - draw - 12/09/09
1 08/04/09 - null.
2 - null - 06/12/09
3 08/12/09 - null.
(forgive the formatting)
Essentially, I want to leave null values and possess a solid column of dates to sort a SELECT with query. Is this possible? If so, how?
The two date columns have type DATE - they are not strings. They also store sometimes, but I don't understand as in the illustration above for simplicity. The columns are two separate tables, but who are joined with a join internal based on an ID value that connects the two (not sure if it's too big).
I am also open to any other ideas about how I could sort the results based on the two sets of dates; Looks like some kind of cartel would be the simplest or most logical (even if I'm wrong, because I can't find a way to do it).
Thank you!
Salvation;
select tableA.id, nvl(tableA.date1, tableB.date2) as combined_dt
from tableA, tableB
where tableA.id=tableB.id
order by 2
Kind regards...
Tags: Database
Similar Questions
-
The order of your columns table Srini Chavali
OK, I made a mistake Srini Chavali.
So why not try to help me now beyond just warn me questions burocratique, what you really should had done to the right place to block my old question responses?
The question is:
How to influence the order of the columns in the table in the time of the transformation of relational logic?
Nelson Alberti da Rosa[] Allow columns reorganize during Engineering (value default Tables)
you in the dialog table as well, and you can set the default value in the preferences.
If disabled for table, column order want to be changed on the next genius of logic to the relational model.
It is automatically cleared if you rearrange the columns manually.Philippe
-
Script to find duplicates in a row and combine the data in specific column
Looking for a script to find duplicates in a line like below...
"VM1', 'VM', 'LDEV', 'LDEV1', 'LDEV2', 'LDEV3', 'LDEV4', 'LDEV5', 'LDEV6 '.
'VM', 'VI-SVC-VM001', "0000ef ', ' '," "," "," "," ""
'VM', 'VI-SVC-VM001', "0000de ', ' '," "," "," "," ""
'VM', 'VI-SVC-VM002', "0000df ', ' '," "," "," "," ""
'VM', 'VI-SVC-VM002', "0000f0 ', ' '," "," "," "," "".. .and manipulate the data in the following:
"VM1', 'VM', 'LDEV', 'LDEV1', 'LDEV2', 'LDEV3', 'LDEV4', 'LDEV5', 'LDEV6 '.
"" 'VM', 'VI-SVC-VM001', '0000ef', "0000de ', ' ', ' '," "," ""
"" 'VM', 'VI-SVC-VM002', '0000df', "0000f0 ', ' ', ' '," "," ""(Note: VM VI-SVC-VM001 object has two LDEVs him assigned 0000ef and 0000de)
There may be two, three, or n LDEVs attributed to each VM object. I guess I have to build a table and the "join-collections" script can't cut it on this one.
I have the process to follow, I just need to put it in a loop (note, data already sorted on the virtual computer object):
1 import-csv
2. read each line, matched VM object, copy each found LDEV and place it in the next LDEV along
3. remove the duplicate line
4. rinse, repeat until the end
Thank you.
It's a solution pleasant Luc. I didn't use the Group-Object cmdlet to solve this problem.
Now I can go to sleep without having to worry about this problem more.
-
How to change the order of the field name in the list?
Hi all
I use a JavaScript taken on the forums, that does what I need beautifully (thanks Gilad D) with 1 small Ride. The script takes the name from fields of those fields that are marked as being necessary, but has been left blank. I named the fields match the number of question so that the user will have a reference. However the order is sorted numerically which means "#1" is followed by "#10"...»
1 - list allowing installation
10 - date sent
2 - name of the person designated by
3 - the exam date
etc.
Is it possible to change this order? This is the script I use:
var emptyFields = [];
for (var i = 0; i < this.numFields; i ++) {}
var f = this.getField (this.getNthFieldName (i));
If (f.type! = "button" & & f.required ") {}If ((f.type=="text" & & f.value== "") |) (f.type == "checkbox" & & f.value == "Off"). (f.type=="combobox" & & f.value== "")) emptyFields.push (f.name);
}
}If (emptyFields.length > 0) {}
App.Alert ("Please verify that the following fields are filled (if any)" before you continue: \n "+ emptyFields.join ("\n")");
}
Thank you!
Yes, after the box print dialogue, but before the file is sent to the
printer. This cannot be changed.
-
Change the order of the fields in the interactive report
I changed the sql code in the definition of the region and the report attributes, but still the columns are not changed?You need to change the default report parameters to display the columns in the desired order. Here's how you can do it.
Run the report. Click on "Action Menu" (the Green mechanical wheel that appears in the search bar) and click on "select columns". Organize the order of your columns here click on 'apply '. Click again on "Action Menu", then click "save report". To "Save" selection list, select 'Default report settings'. Click on apply.
Now, all users see the columns in the order you specified.
[Amédro (PMP, CMO & OCP) Juliette - DBCON | http://www.dbcon.com.sg]
-
sort a single column in the order the asc and desc
How can I write a query to sort a column in the order the asc and desc?
I tried with the following query, but it gives an error-
Select ename, (select ename from emp by ename desc) to order the CSA ename emp;
You try to do this?
SQL > ed
A written file afiedt.buf
1 with t as (select ename
2, row_number() (any order by ename): the nurse
3, count (*)-(row_number () () (any order by ename)-1) as the rn2
4 of PEM
5 )
6. Select e1.ename
7, e2.ename
8 t e1
Join 9 t e2 on (e1.rn = e2.rn2)
10 * order by e1.rn
SQL > /.
ENAME ENAME
---------- ----------
ADAMS WARD
ALLEN TURNER
BLAKE SMITH
CLARK SCOTT
FORD MILLER
JAMES MARTIN
KING JONES
KING JONES
MARTIN JAMES
MILLER FORD
SCOTT CLARK
BLAKE SMITH
ALLEN TURNER
DISTRICT ADAMS
14 selected lines.
But why you want to do this, I don't know.
Edited: to correct error in the code
-
How to view the columns (and the sequence and sort order) an index?
Suppose I have an INDEX for an existing TABLE.
How can I know the columns covered by this INDEX (and the sequence and sort order)?
Which table contains this information?
ALL_INDEXES does not work.
Peteruser559463 wrote:
Suppose I have an INDEX for an existing TABLE.How can I know the columns covered by this INDEX (and the sequence and sort order)?
Which table contains this information?
ALL_INDEXES does not work.
Peter
--
Select the table table_name, column_name, index_name, and position_colonne
of user_ind_columns
order by table_name, index_name, position_colonne; -
How to change the order of the column OR the addition of a space ' ' in front of a filtering value
I'm using Oracle Dashboard OBIEE 11. I have a bar chart that contains three columns 'less than 1 day', '1 to 2 days' and 'more than 2 days. It is produced by the following code.
CASE WHEN TIMESTAMPDIFF (SQL_TSI_DAY, "breakdown of DSR" "." ") Was held Date', 'DSR failure". ("" Resolved to Date ") < 1 THEN 'less than 1 day' WHEN TIMESTAMPDIFF (SQL_TSI_DAY,"Failure of DSR". "Occurred Date", "breakdown of DSR" "." " Resolved Date") > = 1 AND TIMESTAMPDIFF (SQL_TSI_DAY," breakdown of DSR"". "") Was held Date', 'DSR failure". ("" Resolved to Date ") < = 2 THEN 1 to 2 days WHEN TIMESTAMPDIFF (SQL_TSI_DAY," breakdown of DSR"". "") Was held Date', 'DSR failure". ("" Resolved to Date ") > 2 THEN 'more than 2 days' END
NOTE the space "" which is just before "less than a day" which is in bold in the above code. Well, then the reason why I did is if the bar graph CONTROL is proving to be "less than one day" first, then "1-2 days" comes in second, and then 'more than 2 days' comes in last.
NOW, I created an action link that goes to a details page that is filtered by the big piece of code above. The PROBLEM is that filtering somehow removes the space in front of "less than 1 day" and does not recognize this filter. Oh woe me.
Okay, so the two solutions I can think is:
1 remove the space in front of 'less than a day', BUT then the bar chart is ordered by 1 to 2 days, 'less than 1 day' and 'more than 2 days. Yuck. How to reorganize the bar chart?
OR
2. let the link action recognize that there is a SPACE in front of "less than a day." How to do the link action acknowledge that DESPITE me already put in 'less than 1 day'... < review space forward > GAHHHHH T_T
~ Kevin Sun
Hey Kevin,
In this kind of situation, I usually take the option of 2 columns: same BOX WHEN once put in numerical values (in your case can be 1, 2, 3 or something like that), and once put in labels (without spaces or any other thing in front, just real label).
The first with numerical values is hidden and serves to force the second sorting.
In this case, your link action passes the correct value and everything will work. And in the case where a while, you need to change all your labels or something else you can do without thinking about what character to put in front of your labels to fix your sorting.
-
How to conditionally sort a bar graph without displaying the order in OBIEE 11 g?
Hello all;
Draw a graph with revnue on the X axis and name of the product on the axis Y. I am trying to sort the name of the product based on the conditional sort order (requirement) and I've had to date. I don't want to be displayed, although the sort order. Get rid of the data labels is to get rid of the sort order and the number of revenue at the same time I can't afford. Could you please suggest a solution.
Thanks for your help.
Hello
Move your 'Sort order' column in the 'Group By' next to 'Product', make sure it is above 'Product' (to the order of products).
Finally do just your hidden column and you will not see on the list, but it will always adjust the sort order of your products.
-
conditional order by in column sorting
Hello
I use ADF 12.1.2. I have a table that displays the status in a column that is sortable. Instead of sorting in ascending or descending order, I want to sort according to a condition (case ie STATUS when 'Start' then 1 the expression 'ongoing' then 2 etc.). Is it possible to set this using sortCriterion?
For example: I want the column to sort according to the value of the State (that is to say in the order of started, in progress, completed, archived) and not asc or desc.
What I've tried is currently
I have a managed bean that I'm calling from the sortListener of the table. In the managed bean, I can put the sortCriterion to another column, but how to set the condition of SQL database.
Thank you
A
Hello
Here's what I'd do:
1. create a transitional attribute to translate sorting (better is to do it at the level of the entity and vo). You use an expression to evaluate the STATUS attribute and set the attribute value 1 if STATUS = 'start' etc.
2. you then expose the transitional attribute in the binding of the tree to the table (Select link PageDef tree, pencil icon press, shuffle transitional attribute for a list)
3. change the attribute on the af sortProperty: column to point to the transient attribute name so that sorting happens on your transient attribute (see http://docs.oracle.com/cd/E28280_01/apirefs.1111/e12419/tagdoc/af_column.html)
You don't need SQL in this way you can access the STATUS attribute on the transitional attribute by using a Groovy expression (something along the lines of the STATUS == 'start'? 1: (STATUS == 'ongoing'? 2: 3)
Frank
-
What's the point of having several columns in the ORDER BY clause?
DB version: 10 gr 2
When you use the ORDER BY clause, the lines are always sorted by the first column in the ORDER BY clause. So, what's the point of having several columns in the ORDER BY clause (I always see this in production codes)?
For the below SQLs' schema SCOTT, result sets are always classified according to the first column ename. When I added use asc and desc of employment, does not change the result set.
SQL> select * from emp order by ename; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected. SQL> select * from emp order by ename, job; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected. SQL> select * from emp order by ename, job desc; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected.
Search in this example, you will see the difference
SQL> create table test_order (name varchar2(10), surname varchar2(10), age number); Table created. SQL> insert into test_order values('Kamran','Agayev',26); 1 row created. SQL> insert into test_order values('Kamran','Taghiyev',26); 1 row created. SQL> insert into test_order values('John','Kevin',23); 1 row created. SQL> select * from test_order; NAME SURNAME AGE ---------- ---------- ---------- Kamran Agayev 26 Kamran Taghiyev 26 John Kevin 23 SQL> select * from test_order 2 order by age; NAME SURNAME AGE ---------- ---------- ---------- John Kevin 23 Kamran Agayev 26 Kamran Taghiyev 26 SQL> select * from test_order 2 order by age asc, surname desc; NAME SURNAME AGE ---------- ---------- ---------- John Kevin 23 Kamran Taghiyev 26 Kamran Agayev 26 SQL>
When in the second query, I sorted out only for age, you saw it there two 26 years old Keita, there was first Agayev, then Taghiyev. But if I want to get the family names in descending order when there are two very old person, then I will add the second column in the order by clause
- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev a. (10g OCP)
http://kamranagayev.WordPress.com -
Combine the rows based on the value of the column
I try to combine lines based on a common value.
Data in the table:
Result A
Here are my main request...Player_ID Player_Name Team_Name Points Sequence 99999 John Smith Bulls 50 1 99999 John Smith Pistons 14 2 What i want in the output Result B Player_ID Player_Name Team_Name Points 99999 John Smith Bulls 64 (50 for Bulls)
Current query gives me the result of the result of Aselect player_id, player_name, team_name, points from ( SELECT player_id, player_name, team_name, sum(points) sum_points FROM stats_data WHERE season_id = 2008 AND points > 0 GROUP BY player_id, player_name, team_name ) t ORDER BY sum_points DESC, last_name;
(1) not entirely sure how, to combine the player_id basic data
2) once I found 1, I'm sure that by adding the ("sum_points" for "team_name") to the output can be done with a case statement, I think?Hello
Thank you.
Let me make sure I understand: If a player on two or more teams, the one with the largest value of the sequence appears in the column team_name. Others will be displayed, in the order of sequence, in the points column.
This done:
WITH gb1 AS ( SELECT player_id, player_name, team_name, sequence , SUM (points) AS sum_points , ROW_NUMBER () OVER ( PARTITION BY player_id, player_name ORDER BY sequence DESC ) AS r_sequence , STRAGG (' ' || SUM (points) || ' for ' || team_name) OVER ( PARTITION BY player_id, player_name ORDER BY sequence ) AS all_points FROM game GROUP BY player_id, player_name, team_name, sequence ) SELECT player_id , player_name , MIN (team_name) KEEP (DENSE_RANK FIRST ORDER BY r_sequence) AS team_name , TO_CHAR (SUM (sum_points)) || MAX ( CASE WHEN r_sequence > 1 THEN ' (' || REGEXP_REPLACE ( SUBSTR (all_points, 2) , ' ,[^,]$' ) || ')' END ) AS points FROM gb1 GROUP BY player_id, player_name ORDER BY player_id, player_name;
The information listed in points (e.g. '(16 pour les TAUREAUX, 4 pour les PISTONS) ') requires the aggregation of the chain.
[AskTom.oracle.com | http://asktom.oracle.com/pls/asktom/f?p=100: 11:0:P11_QUESTION_ID:2196162600402] shows several ways to do so.
I used the first option on this page, the function defined by the user STRAGG, that you can copy from this page.You can have a similar function, the WM_CONCAT (property WMSYS), already installed.
WM_CONCAT is not documented, so you can't use it in your Production applications. -
When I find an image that I want to save, I choose to save the Image under. Navigate to an existing folder, but the items are not ordered by name. I right click on the window save as and choose Arrange by name. The work of sorting and I recorded my element. Later, when I return in the same folder that the elements are not ordered by name. I want that option "arrange by name' to be permanent.
The same as with a file browser. The bar at the top of the window.
name, size, date ... click on what you want. -
How do sort you the order account shown in the folders pane in Thunderbird?
When dealing with multiple email accounts in Thunderbird, how can I arrange the order that they are listed in the pane of the files of the main window, the broad view, the version of Mac OS X? When I add new accounts, they placed in the order want to Thunderbird, is usually not the one I need.
Shift, control, Option, or command key does not move them. With the help of v24.6.0 on OS X 10.7.5.
https://addons.Mozilla.org/en-us/Thunderbird/addon/manually-sort-folders/
http://chrisramsden.vfast.co.UK/3_How_to_install_Add-ons_in_Thunderbird.html
-
I want to be able to change the sort order of the items, I already looked in the search box. I want to be able to hit the arrow key down and see my previous searches in order of last search showing the first. For the moment, I don't know how it is sorting and it is very annoying to have to re - enter a query that I typed 5 minutes earlier, but because I typed in another 10 since it's lost somewhere in the list. Is it possible, I Googled, but did not find the topic anywhere. Just to clarify, I DON'T mean of the order of the search engines (which is what appears in google), I mean that the text typed into which has been registered in the drop-down list.
Thank you
'Form filling' uses a "frecency" algorithm, frequency + recency, similar to the list of AutoComplete address bar.
I found an extension that seems relevant, but critics are old, so I'm not sure it's still working: Searchbar Autocomplete Order.
But... is the AutoComplete does not? I expect that typing a few characters of the previous query would be to filter the list so that you can easily select? Or is the problem that the list does not remember quite who looking for?
Maybe you are looking for
-
Where can I get El Capitan.
I have mid-2009 Mac book pro running Yosemite 10.10.5. Notes is not synchronized with my 6. iPhone and my iPad. I read that I can not go to Sierra. Y at - it somewhere I can get El Capitan?
-
Portege 3500 stylus works does not in some parts of the screen
My stylus on my portege does not work in some parts of the screen parts change and are sometimes not there.This happened after the replacement of the screen, but not right away.
-
F100-NH Pavilion: Pavilion HP KEYBOARD PROBLEM
Hello world! I have a laptop HP Pavilion F100-NH with Win 8.1. 2 weeks before my keyboard has a problem. I started windows and I couldn't type anything. I removed the keyboard from the Device Manager, and then I restarted > it would be OK. But today,
-
Original title: reactivation. I bought Office Home and Student 2010 when I bought a new laptop. Over time, I have had problems with laptop computer and had to reload Office several times. Now, I bought another laptop and when I try to load the office
-
I'm trying to get tha 360 to post a link with my vista computer. I see the pc on the xbox and the xbox to the pc, but they do not speak. If that makes sense?