Merge Two Columns in a Single Column
Dear,
Inputs
Table1 |
Col1 (Number) |
1 |
2 |
3 |
4 |
5 |
6 |
and table 2
Table2 |
Col1 (Number) |
7 |
8 |
9 |
10 |
11 |
12 |
No relation between the two tables
I want to write a select statement that will result
Column
1
2
3
4
5
6
7
8
9
10
11
12
No sorting is required, I just need to have all the values listed in a single column... How can I do?
Thanks in Advance.
If there is dup values between the two tables and you want get only unique, use UNION. If not UNION ALL as already stated.
Nicolas.
Similar Messages
-
How to concatenate two colums into one single column
I need some ideas to concatenate two different columns into one single column using a set of distinct values.
For Example,
Customer Product Number
xyz A 1
xyz B 2
xyz B 1
AAA C 7
AAA A 1
The result should look like this,
Customer Value
xyz A1 B2 B1
AAA C7 A1
How would I group this into once value ?
Thanks in advance ...Tom's discussion of writing your own aggregate routines
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:2196162600402
starts off with a link to the 8i alternatives
"see
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:229614022562
for 8i methods (not aggregates)"
Unforutnately, it's a lot more work in 8i.
Justin -
Combining two columns into a single column
Hi,
I have a VC Iview which displays the data of a query in a table .
Output in a Table
......................<<Quantity>> <<Unit>> <<Amount>> <<Currency>>
&&Sales&&
Is it possible in VC to combine "Quantity" column and "unit" column to a single column say "Quantity"
similarly "Amount" column and "currency" column to a single column"Amount"
I.e i wanted to show the values in a single column some thing like this:
&&Sales:&& <<120 Kg>> <<500 Dollars>> ( 2 columns )
Instead of( 4 columns) :
&&Sales :&& << 120>> <<Kg>> <<500>> <<Dollars>>
Thanks
P.NavakanthHi,
You could hide your actual columns for Quanity and unit and create one more column of type expression box in your table that will concatenate the value of quantity and unit.
Regards,
Murtuza Kharodawala -
Merging two records in a single record for the same matnr,werks and bwart.
Hi I have a requirement to merge two records into one single record using the quantity field from MSEG table.
I am selecting two records from the table MSEG. Now for these two records i have to add the quantity values into one variable.
Then there should be only one record for the same matnr,werks,bwart.
Any suggestion would be appreciated.
Regards,
Amithi,
You can COLLECT statement only if all non key fields are numeric.
This statement Adds all such fields and give us a single record.
Regards
Sumit Agarwal -
Displaying 2 columns in a single column using HTML section of reports.
Hi Team,
I have a requirement in which we need to display 2 columns in the same column of OBIEE report. At present we have 2 columns as 2 different columns.
For example if i have a column A which is used as @A in html section i need the new column to have @A + @B where B is another column in database.
Can i concatenate 2 columns in a single column ?
Thanks,
Riteshfirst select column 1 and column 2 in criteria.
go to reaults are add narrater view.
in narrater view type.
@1@2[br/]
set number of rows
this should work in narrator.
Edited by: user10615659 on May 20, 2013 4:30 PM -
Merge two column value in single column
Team,
I have a requirement where in I need to merge 2 column values in a single column.
ex. I have Percent_complete column in my table. and my table has only one record.
I need to query such that I need to store the values of percent_complete and (100- percent_complete) values in a single column.
ex
Percent complete has 30 value.
I need to select 30 and 70(100-30) both in a single column.
Thanks,SQL> select *
2 from tbl
3 /
PERCENT_COMPLETE
30
SQL> select abs(grouping(1) * 100 - max(percent_complete)) percent_complete
2 from tbl
3 group by rollup(1)
4 /
PERCENT_COMPLETE
30
70
SQL> select nvl(percent_complete,100 - max(percent_complete)) percent_complete
2 from tbl
3 group by rollup(percent_complete)
4 /
PERCENT_COMPLETE
30
70
SQL>
SY. -
Merging Two Views in a Single Role
Hello All,
I wanted to Merge two iviews with in a single role.Consider the below example.
See, i have a role called "Role A"(TLN1 Entry) and i have two url views( iView1 and iView2) which needs to be added and it should fall under the as TLN2 entry.
Now i have two set of groups( Group A and Group B) , if i add this role to these two groups, users who all are part of "Group A" should see the "iView1" and users who all are part of "Group B" should see the "iView2".
I have read some help documentation, but i could understood the concept of merging.But i would like to know, how this can be achieved.
Please help me.
Thanks In Advance.
Best Regards,
Manoj KHello both,
Thanks for the quick reply.
I am clear now. But one thing which i would like to know, is there any possibility, if these two iviews are assigned to a single role, and this roles is assigned to two groups, basically group A and group B, only one group of people can should see Iview1 and other group of people should see iview2.( As per i know, access can be organized via roles, but still i wanted to check with you is there any provision where i can achieve this.
Thanks for helping me.
Best Regards,
Manoj K -
How to disable JTable Column Dragging (only single column)
How could i disable a single column from being dragged in JTable?
I need to fix the first column from being dragged in JTable and all other columns except the first can be dragged. how would i accomplish this task ?
well, i know how to fix all column in jtable from being dragged using
table.getTableHeader().setReorderingAllowed(false);But dont know how to fix only a single column. is there any method for doing this. or i have to implement any other logic?
Please help me !
ThanksThe question is why do you have this requirement. I figure if the user wants to reorder the colum, let them, the table won't break.
Maybe something like this would be acceptable:
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class FixedColumnScrollPane extends JScrollPane
public FixedColumnScrollPane(JTable main, int fixedColumns)
super( main );
// Use the table to create a new table sharing
// the DataModel and ListSelectionModel
JTable fixed = new JTable( main.getModel() );
fixed.setFocusable( false );
fixed.setSelectionModel( main.getSelectionModel() );
fixed.getTableHeader().setReorderingAllowed( false );
// fixed.getTableHeader().setResizingAllowed( false );
fixed.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
main.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
// Remove the fixed columns from the main table
for (int i = 0; i < fixedColumns; i++)
TableColumnModel columnModel = main.getColumnModel();
columnModel.removeColumn( columnModel.getColumn( 0 ) );
// Remove the non-fixed columns from the fixed table
while (fixed.getColumnCount() > fixedColumns)
TableColumnModel columnModel = fixed.getColumnModel();
columnModel.removeColumn( columnModel.getColumn( fixedColumns ) );
// Add the fixed table to the scroll pane
fixed.setPreferredScrollableViewportSize(fixed.getPreferredSize());
setRowHeaderView( fixed );
setCorner(JScrollPane.UPPER_LEFT_CORNER, fixed.getTableHeader());
public static void main(String[] args)
// Build your table normally
JTable table = new JTable(10, 8);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JScrollPane scrollPane= new FixedColumnScrollPane(table, 1 );
JFrame frame = new JFrame("Table Fixed Column Demo");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.getContentPane().add( scrollPane );
frame.setSize(400, 300);
frame.setVisible(true);
}Or maybe you should be using a Row Header. A row header is like the column header of JTable. It remains fixed on the left side of the scroll pane. Search the forum for examples using "setrowheaderview". -
Merge Two Tables with the same columns but different data
I have a table that has the following columns:
Current Table Definition
commonname
family
genus
species
subspecies
code
I have a number of entries that donât fit the current table definition â that is that they only have a common name or description and a code. These records donât actually represent a species but are needed for data entry because they represent an object that may be encountered in the study (Bare Ground â which isnât a species but would need to be recorded if encountered). So I would really like 2 tables:
Table 1 Miscellaneous
name
code
Table 2 Plant Species
commonname
family
genus
species
subspecies
code
I would like two tables so I can enforce certain constraints on my species table like requiring that the family, genus, species, subspecies combination is unique. I canât do this if I have all the âotherâ records that donât have a family, genus, species, or subspecies unless I put in a lot of dummy data into the fields to make each record unique. I donât really want to do this because these miscellaneous records really donât represent a specific species.
So â the problem is that while I want this data separate I will need to point a column from another table to the code column in both tables.
How is this best done? Table? View? Merge?Hi,
Actually you don't have to use scope refs. Sorry but I misunderstood you earlier. Here is a complete example that does exactly what you want. Notice how I added the constraint to the materialized view. Also notice when we try to insert a code in tbl3 that doesn't exist in the view, we get an error. HTH.
SQL> create table tbl1 (name varchar2(10), code varchar2(3) primary key);
Table created.
SQL> create table tbl2 (commonname varchar2(10), code varchar2(3) primary key);
Table created.
SQL> insert into tbl1 values ('n1','c1');
1 row created.
SQL> insert into tbl1 values ('n2','c2');
1 row created.
SQL> insert into tbl1 values ('n3','c3');
1 row created.
SQL> insert into tbl2 values ('name1','c1');
1 row created.
SQL> insert into tbl2 values ('name2','c2');
1 row created.
SQL> insert into tbl2 values ('name3','c3');
1 row created.
SQL> commit;
Commit complete.
SQL> create materialized view view1 as select name, commonname, tbl1.code from tbl1, tbl2 where tbl1.code = tbl2.code;
Materialized view created.
SQL> select * from view1;
NAME COMMONNAME COD
n1 name1 c1
n2 name2 c2
n3 name3 c3
SQL> create table tbl3 (code varchar2(3), record varchar2(1));
Table created.
SQL> alter table view1 add constraint view1pk primary key (code); -- <-Note how I added a constraint to the view
Table altered.
SQL> alter table tbl3 add constraint tbl3fk foreign key (code) references view1(code);
Table altered.
SQL> insert into tbl3 values ('c1','r');
1 row created.
SQL> insert into tbl3 values ('c99','r');
insert into tbl3 values ('c99','r')
ERROR at line 1:
ORA-02291: integrity constraint (RAJS.TBL3FK) violated - parent key not found
SQL> spool of;
-Raj Suchak
[email protected] -
Data with two rows in a single column
I have been working on a report with the customer due amounts shown in bucketed columns eg 1-30 , 31-60 etc for each Customer,
so for each column I want to show an additional row with the % of the due amounts for each bucketed column.
. The format of report should look like below in pivot/table view
|Customer| |Due1-30 | Due31-60 | Due60+ | Total |
|XYZ | | 3000 | 2000 | 5000 | 10000 |
| |%Due | 30% | 20% | 50% | 100% |
ABC….
I have to get the percentages on the measure values in a separate row(not as a seperate column). Could you please help me how to get result like the format what I have shown
Thanks,
BP
Edited by: user8116383 on May 6, 2011 8:55 AMHi
This can be achievable by using Pivot view.
1.In Columns field place the customer and place the measure lables in the rows field and the measure column in measure field.
2.Duplicate the measure column and name it as %Due and click more options on this duplicated column and click shown data as -> percent of -> Row
Thanks
Diney -
How to place two constraints on a single column
hii
i have a column which will store data in date format
now i need all the records whose value is not null in tht column and date should be from last week to current week
is there any other way to write query other than like this
let us assume its terminate date coloumn
select * from <tablename>
where terminate date is not null
and terminate date between sysdate+7 and sysdate-7
or
select * from <tablename>
where terminatedate between sysdate-7 and sysdate+7
and terminatedate not nullErr... ok I may have said that wrong...
But I still think it might be exclusive, no?
eg. you store 1, 2, 3, 4 and 5 in a table.
select *
from table
where number between 1 and 5
and you will get 1, 2, 3, 4
That is exclusive of the second value.
That is the standard definition of exclusive.
Inclusive includes the last value (eg. 5).
Exclusive does not.
There is the exception of the time, which I would like to know more about.
I don't mean to ruffle everyone's feathers though!
Sorry if I sound like a know-it-all :P
I freely admit that I don't!!
So back onto the time thing...
Say if I store...
01/01/07 00:50:00
01/01/07 18:20:00
02/01/07 05:35:00
02/01/07 20:20:00
03/01/07 00:00:05
03/01/07 23:50:00
in a table
and i go
select *
from table
where date between to_date('01/01/07','dd/mm/yy') and to_date('03/01/07','dd/mm/yy')
Won't I get
01/01/07 00:50:00
01/01/07 18:20:00
02/01/07 05:35:00
02/01/07 20:20:00
back?
and if i go
select *
from table
where date between to_date('01/01/07','dd/mm/yy') and to_date('04/01/07','dd/mm/yy')
OR
select *
from table
where date between to_date('01/01/07','dd/mm/yy') and to_date('03/01/07 23:59:59','dd/mm/yy HH24:MI:SS')
I'll get them all? -
Two dashboard prompts on single column expression
Hi
i need to use 2 dashboard prompts
currency-transactional,operational,reporting
period--ptd,ytd,qtd
i have netamount ,reporting netamount,operational netamount columns
i calculated ptd,qtd,ytd in rpd
iam using currency and period as prompts
how to do thisHi veera
now iam give clearly
on the netamount column i apply presentation variable for ptd,ytd,qtd
then period prompt is working
and im apply another promt currency
if weselect currency-transactional and currency=ptd in prompt
then it give transactional ptd netamount
if weselect currency-reporting and currency=ptd in prompt
then it give reporting ptd netamount
like this i get the values
please give some detail help with sample example -
Merging two rows into a single row
Hi ,
I wish to merge few columns of tow rows into a single row.
if i use union it gives two rows as o/p.
What is the exact sql statement for that?
ThanksHi Sridhar,
This is my code for merging and i used union.
Suggest me good solution.
CREATE OR REPLACE VIEW INSPECTINT.INSPECT_LOC_TRACKING_RPT_VIEW AS
SELECT
VEN_COMPANY_NAME VEN_COMPANY_NAME,
VEN_COMPANY_NAME_2 VEN_COMPANY_NAME_2,
VEN_CONTACT_FIRST_NAME VEN_CONTACT_FIRST_NAME,
VEN_CONTACT_MIDDLE_NAME VEN_CONTACT_MIDDLE_NAME,
VEN_CONTACT_LAST_NAME VEN_CONTACT_LAST_NAME,
VEN_ADDRESS_LINE_1 VEN_ADDRESS_LINE_1,
VEN_ADDRESS_LINE_2 VEN_ADDRESS_LINE_2,
VEN_CITY VEN_CITY,
VEN_CNT_COUNTY_CODE VEN_CNT_COUNTY_CODE,
VEN_STC_STATE_CODE VEN_STC_STATE_CODE,
VEN_ZIP_CODE VEN_ZIP_CODE,
VEN_PHONE_NO_1 VEN_PHONE_NO_1,
VEN_PHONE_EXTN_1 VEN_PHONE_EXTN_1,
VEN_PHONE_NO_2 VEN_PHONE_NO_2,
VEN_PHONE_EXTN_2 VEN_PHONE_EXTN_2,
VEN_FAX_NO_1 VEN_FAX_NO_1,
VEN_VENDOR_NO VEN_VENDOR_NO,
VEN_APV_AP_VENDOR_ID VEN_APV_AP_VENDOR_ID,
VEN_EMAIL_ADDRESS VEN_EMAIL_ADDRESS,
--all these should be null
to_number(NULL) PHY_LCN_PARAMETER_ID,
to_char(NULL) PHY_LCN_CURRENT_ADDRESS_IND,
to_char(NULL) PHY_LCN_STATUS_CODE,
to_char(NULL) PHY_LCN_LTY_LOCATION_TYPE,
to_char(NULL) PHY_LCN_ADT_ADDRESS_TYPE,
to_char(NULL) PHY_LCN_HOUSE_NO,
to_char(NULL) PHY_LCN_ADDRESS_LINE_1,
to_char(NULL) PHY_LCN_ADDRESS_LINE_2,
to_char(NULL) PHY_LCN_CITY,
to_char(NULL) PHY_LCN_STC_STATE_CODE,
to_char(NULL) PHY_LCN_ZIP_CODE,
to_char(NULL) PHY_LCN_CNT_COUNTY_CODE,
to_date(NULL) PHY_END_DATE,
to_number(NULL) PHY_LCN_VEN_VENDOR_ID_GTA,
to_char(NULL) PHY_LCN_SUB_LOCATION_GTA,
to_char(NULL) PHY_LCN_DIRECTION_GTA,
---all these should be null
to_char(NULL) LOW_LCN_PARAMETER_ID,
to_char(NULL) LOW_LCN_CURRENT_ADDRESS_IND,
to_char(NULL) LOW_LCN_STATUS_CODE,
to_char(NULL) LOW_LCN_LTY_LOCATION_TYPE,
to_char(NULL) LOW_LCN_ADT_ADDRESS_TYPE,
to_char(NULL) LOW_LCN_HOUSE_NO,
to_char(NULL) LOW_LCN_ADDRESS_LINE_1,
to_char(NULL) LOW_LCN_ADDRESS_LINE_2,
to_char(NULL) LOW_LCN_CITY,
to_char(NULL) LOW_LCN_STC_STATE_CODE,
to_char(NULL) LOW_LCN_ZIP_CODE,
to_char(NULL) LOW_LCN_CNT_COUNTY_CODE,
to_char(NULL) LOW_LCN_LANDLORD,
to_number(NULL) LOW_LCN_LANDLORD_PHONE,
to_date(NULL) LOW_END_DATE,
to_char(NULL) LOW_LCN_SUB_LOCATION_GTA,
to_char(NULL) LOW_LCN_DIRECTION_GTA
FROM LOCATIONS LOC , VENDORS VEN
WHERE LOC.LCN_VEN_VENDOR_ID_GTA IS NOT NULL
AND LOC.LCN_VEN_VENDOR_ID_GTA = VEN_VENDOR_ID
AND LOC.LCN_LTY_LOCATION_TYPE ='AS'
UNION ALL
SELECT
to_char(NULL) VEN_COMPANY_NAME,
to_char(NULL) VEN_COMPANY_NAME_2,
to_char(NULL) VEN_CONTACT_FIRST_NAME,
to_char(NULL) VEN_CONTACT_MIDDLE_NAME,
to_char(NULL) VEN_CONTACT_LAST_NAME,
to_char(NULL) VEN_ADDRESS_LINE_1,
to_char(NULL) VEN_ADDRESS_LINE_2,
to_char(NULL) VEN_CITY,
to_char(NULL) VEN_CNT_COUNTY_CODE,
to_char(NULL) VEN_STC_STATE_CODE,
to_char(NULL) VEN_ZIP_CODE,
to_number(NULL) VEN_PHONE_NO_1,
to_number(NULL) VEN_PHONE_EXTN_1,
to_number(NULL) VEN_PHONE_NO_2,
to_number(NULL) VEN_PHONE_EXTN_2,
to_number(NULL) VEN_FAX_NO_1,
to_char(NULL) VEN_VENDOR_NO,
to_char(NULL) VEN_APV_AP_VENDOR_ID,
to_char(NULL) VEN_EMAIL_ADDRESS,
decode(lcn_adt_address_type,'P',to_number(LCN_PARAMETER_ID),to_number(NULL)) PHY_LCN_PARAMETER_ID,
decode(lcn_adt_address_type,'P',LCN_CURRENT_ADDRESS_IND,to_char(NULL)) PHY_LCN_CURRENT_ADDRESS_IND,
decode(lcn_adt_address_type,'P',LCN_STATUS_CODE,to_char(NULL)) PHY_LCN_STATUS_CODE,
decode(lcn_adt_address_type,'P',LCN_STATUS_CODE,to_char(NULL)) PHY_LCN_LTY_LOCATION_TYPE,
decode(lcn_adt_address_type,'P',LCN_ADT_ADDRESS_TYPE,to_char(NULL)) PHY_LCN_ADT_ADDRESS_TYPE,
decode(lcn_adt_address_type,'P',LCN_HOUSE_NO,to_char(NULL)) PHY_LCN_HOUSE_NO,
decode(lcn_adt_address_type,'P',LCN_ADDRESS_LINE_1,to_char(NULL)) PHY_LCN_ADDRESS_LINE_1,
decode(lcn_adt_address_type,'P',LCN_ADDRESS_LINE_2,to_char(NULL)) PHY_LCN_ADDRESS_LINE_2,
decode(lcn_adt_address_type,'P',LCN_CITY,to_char(NULL)) PHY_LCN_CITY,
decode(lcn_adt_address_type,'P',LCN_STC_STATE_CODE,to_char(NULL)) PHY_LCN_STC_STATE_CODE,
decode(lcn_adt_address_type,'P',LCN_ZIP_CODE,to_char(NULL)) PHY_LCN_ZIP_CODE,
decode(lcn_adt_address_type,'P',LCN_CNT_COUNTY_CODE,to_char(NULL)) PHY_LCN_CNT_COUNTY_CODE,
decode(lcn_adt_address_type,'P',END_DATE,to_char(NULL)) PHY_END_DATE,
decode(lcn_adt_address_type,'P',LCN_VEN_VENDOR_ID_GTA,to_char(NULL)) PHY_LCN_VEN_VENDOR_ID_GTA,
decode(lcn_adt_address_type,'P',LCN_SUB_LOCATION_GTA,to_char(NULL)) PHY_LCN_SUB_LOCATION_GTA,
decode(lcn_adt_address_type,'P',LCN_DIRECTION_GTA,to_char(NULL)) PHY_LCN_DIRECTION_GTA,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_PARAMETER_ID,to_char(NULL)) LOW_LCN_PARAMETER_ID,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_CURRENT_ADDRESS_IND,to_char(NULL)) LOW_LCN_CURRENT_ADDRESS_IND,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_STATUS_CODE,to_char(NULL)) LOW_LCN_STATUS_CODE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_LTY_LOCATION_TYPE,to_char(NULL)) LOW_LCN_LTY_LOCATION_TYPE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ADT_ADDRESS_TYPE,to_char(NULL)) LOW_LCN_ADT_ADDRESS_TYPE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_HOUSE_NO,to_char(NULL)) LOW_LCN_HOUSE_NO,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ADDRESS_LINE_1,to_char(NULL)) LOW_LCN_ADDRESS_LINE_1,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ADDRESS_LINE_2,to_char(NULL)) LOW_LCN_ADDRESS_LINE_2,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_CITY,to_char(NULL)) LOW_LCN_CITY,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_STC_STATE_CODE,to_char(NULL)) LOW_LCN_STC_STATE_CODE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ZIP_CODE,to_char(NULL)) LOW_LCN_ZIP_CODE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_CNT_COUNTY_CODE,to_char(NULL)) LOW_LCN_CNT_COUNTY_CODE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_LANDLORD,to_char(NULL)) LOW_LCN_LANDLORD,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_LANDLORD_PHONE,to_char(NULL)) LOW_LCN_LANDLORD_PHONE,
decode(LCN_ADT_ADDRESS_TYPE,'D',END_DATE,to_char(NULL)) LOW_END_DATE,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_SUB_LOCATION_GTA,to_char(NULL)) LOW_LCN_SUB_LOCATION_GTA,
decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_DIRECTION_GTA,to_char(NULL)) LOW_LCN_DIRECTION_GTA
FROM LOCATIONS LOC
WHERE (LCN_LTY_LOCATION_TYPE ='AS' OR LCN_ADT_ADDRESS_TYPE='D')
AND LCN_CURRENT_ADDRESS_IND ='Y'
thanks -
Merging two results into a single row
Hi, Everyone... I think this is a weighted question and I feel like it's a bit difficult to phrase, so if it doesn't make sense - let me know and I'll try to clarify or provide some more concrete examples (if I can) :)
I have a few tables inner joined in my sql query - I'd post the entire query here but it's lengthy and will probably add a bit more confusion so let's start with theorizing - where the results sometimes generate more than one row. If more than one row exists, I'd like to take the lowest number in one field and the highest number in another field, and display them on a single row.
For instance, when I join the PERIOD and SCHEDULE tables, the PERIOD table might provide two rows like the following:
SCHEDULE_ID PERIOD_ID START_TIME END_TIME
123 100 32820 35640
123 101 35940 38760My final result should take the lowest START_TIME and the highest END_TIME, even if they exist is separate rows.
START_TIME END_TIME
32820 38760It doesn't seem easy to me so if someone can make sense of this - you deserve an award. :) If I can provide some more clarification, please let me know. Thanks for any help. Oracle 11g
Edited by: nage62587 on Sep 27, 2012 11:32 AMnage62587 wrote:
Thanks! I'll try that... I have more than these columns in the result and I'm thinking a Group By likely wouldn't work - I will try but in the event it doesn't, does anyone else have any other suggestions?Group by is the correct way to do this. You group several rows of output into one row. Then you decide which values from inside that group you want to see. This is certainly possible. There are more aggregation functions available than you might think, not only min/max, also min/max + KEEP, count(case expression) and so on. -
Displaying multiple columns of a single column query
Would anyone happen to know how to display a result set in multiple horizontal columns as opposed to a single vertical column in ApEx?
Example:
select server_name from owner.servers;
A normal sql report would return:
server1
server2
server3
server4
server5
server6
What I'm looking for is a return that will display:
server1 server2 server3
server4 server5 server6I'm sure there's a much better way, but one thing that popped into my head was to make your report be a Dynamic PL/SQL Region.
If you loop thru the records in a cursor, you can build a string and once you have "three" records, use the htp.p to print it out.
So something like this maybe:
v_count NUMBER(1);
v_data SERVERS.SERVER_NAME%TYPE;
v_string VARCHAR2(100);
CURSOR getdata IS
SELECT server_name
FROM servers
ORDER BY server_name;
BEGIN
v_count := 0;
OPEN getdata;
LOOP
FETCH getdata INTO v_data;
EXIT WHEN getdata%NOTFOUND;
v_count := v_count + 1;
IF v_count = 1 THEN
v_string := rpad(v_data,25,' ');
ELSIF v_count = 4 THEN
htp.p(v_string);
v_count := 1;
v_string := rpad(v_data,25,' ');
ELSE
v_string := v_string||rpad(v_data,25,' ');
END IF;
END LOOP;
CLOSE getdata;
END;
Variable lengths would need to be adjusted to fit your data, but you get the idea (hopefully).
Again, perhaps it's not the most efficient, but it would work.
Chad
Maybe you are looking for
-
Project Server 2013 and email notifications
Hi, Newbie's question: is it possible to set email notifications in Project Server 2013 without Exchange Server, just with gmail or hotmail? Is there somewhere a document for that? Thanks
-
E-Recruiting - Doubt about job for changes in HR system.
Hi, We are on E-Rec 604 with seperated standlone e-rec system. I did the initial transfer of the Org Management and employees data through PFAL from ECC to E-Recruit and all were ok. Now we are planning the job for future changes. The job in e-recrui
-
I'd like very much a daap improvement in ipad... not only family sharing to share music!!! this is pathetic for a nas server support (daap!!!) thanks!!!
-
Create new pages but don't publish yet.
Is it possible to create multiple pages ready for publishing but only publish selected ones today? To clarify if I create 10 pages today but don't want to publish them all today, 5 today 5 tomorrow is there a way to publish them in stages? The publis
-
Help me plz..ㅠㅠ