Values in two columns in Excel
Good morning
I am writing the values to the Excel from 2 sequences, now in the excel it writes one below the other but i like to write in separate columns
Thanks
The simple answer is don't write the header 10 times.
Since you did not post your code or even mention which function you are using, I have no idea how you are creating this file but the general practice would be to write the header in a separate function from what you are using to write the data.
Similar Messages
-
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Need to compare values in two columns of one table against values in two columns in another table
Hi, as the title reads, I'm looking for an approach that will allow me to compare values in two columns of one table against values in two columns in another table.
Say, for instance, here are my tables:
Table1:
Server,Login
ABCDEF,JOHN
ABCDEF,JANE
FEDCBA,SEAN
FEDCBA,SHAWN
Table2:
Server,Login
ABCDEF,JOHN
ABCDEF,JANE
FEDCBA,SHAWN
In comparing the two tables, I'd like my query to report the rows in table1 NOT found in table2. In this case, it'll be the 3rd row of table one:
Server,Login
FEDCBA,SEAN
Thanks.create table Table1([Server] varchar(50), Login varchar(50))
Insert into Table1 values ('ABCDEF','JOHN'),('ABCDEF','JANE'),('FEDCBA','SEAN'),('FEDCBA','SHAWN')
create table Table2([Server] varchar(50), Login varchar(50))
Insert into Table2 values ('ABCDEF','JOHN'),('ABCDEF','JANE'), ('FEDCBA','SHAWN')
select [Server] ,Login from Table1
Except
select [Server] ,Login from Table2
select [Server] ,Login from Table1 t1
where not exists(Select 1 from Table2 where t1.[Server] = t1.[Server] AND Login=t1.Login)
drop table Table1,Table2 -
Hi All,
Am using OPENROWSET to load the file data into table, here the problem is i need to map same input value to two different columns of table, As format file doesn't allow the duplicate numbers am unable to insert same value to two columns, please help me to
find a solution for this.
i can use only OPENROWSET because i need to insert some default values also which come based on file. only the problem is how to map same input value to two different columns of table. please give me the suggestions.
Thanks,
SudhakarFrom what you say:
INSERT tbl(col1, col2)
SELECT col1, col1
FROM OPENROWSET(....)
But I guess it is more difficult. You need to give more details. What sort of data source do you have? What does your query look like? The target table?
Erland Sommarskog, SQL Server MVP, [email protected]
Hi Erland,
Thanks for your response
my source file is text file with | symbol separate for ex:
1002|eTab |V101|eTablet|V100|Logic|LT-7|Laptops|SCM
Database table have columns like
column1,column2,column3...etc, now i need to insert same value from input file into two columns for ex:
the eTab value from text file has to be insert into column2 and column3 of
table
we cannot change format file like below one
for the above situation how can we insert eTab into column2 and column3
Thanks,
Sudhakar. -
Concatinating the values of two columns ???
Hi,
Can anyone help me out in concatenating the values of two columns ??
Please ASAP...
Thanks>
What's wrong with
select (col X || '-'|| Col y ) as Z from xyz_table;
test@ora>
test@ora>
test@ora> --
test@ora> with xyz_table as (
2 select 1 as col from dual)
3 --
4 select (col X || '-'|| Col y ) as Z from xyz_table;
select (col X || '-'|| Col y ) as Z from xyz_table
ERROR at line 4:
ORA-00907: missing right parenthesis
test@ora>
test@ora>
test@ora> --
test@ora> with xyz_table as (
2 select 1 as x, 2 as y from dual)
3 --
4 select (col X || '-'|| Col y ) as Z from xyz_table;
select (col X || '-'|| Col y ) as Z from xyz_table
ERROR at line 4:
ORA-00907: missing right parenthesis
test@ora>
test@ora>
test@ora> -- ==================================================
test@ora> --
test@ora> with xyz_table as (
2 select 1 as col from dual)
3 --
4 select (col || '-'|| Col) as Z from xyz_table;
Z
1-1
1 row selected.
test@ora>
test@ora>
test@ora> --
test@ora> with xyz_table as (
2 select 1 as x, 2 as y from dual)
3 --
4 select (X || '-'|| y ) as Z from xyz_table;
Z
1-2
1 row selected.
test@ora>
test@ora>isotope -
How to Sort one key figure values in two column based on single char
hi gurus,
I would really appreciate if some one can help me out with my question.
I have to design a query based on a Multiprovider built on three ODS, Purchasing, Confirmations & Invoic ODS
Purchase order Value and Number data in PO ODS, and confirmations is in CONFODS, Invoice Values in INV ODS,
The design of the requirement is
Vendor --> PO --> Material PO Value --> Text PO Value --> Confirmation value --> Invoice value
There are Two POS 1. Material PO & 2. Text PO
I need to display all the Purchase orders for a vendor and in different columns i need to display the value of the Material PO and Text PO and their Confirmation Value and how much is the invoiced value for every PO.
Can anybody tell me what should i do in the Query Designer to display the necessary values.
Thank youHi william,
When i put in the PO KF in the column and also the Confirmation KF in other Column it either shows me # for both the entries or it shows me values in only one of the column
if PO is displayed the Confirmation is not displayed and if Confirmation is displayed PO values are shown as # i dont know what wrong i am doing.
if you have idea can you tell me what i should do when i want two different values from two ODS if there are no characteristics that are matching in either of the ODS should i go for Multi Provider and if so how should be my designing. i would really appreciate if you can tell me taking a scenerio.
Thanks -
Single column value into two column of report
Hi frnds,
I have a column of Adress in my databse table from where i have to fetch values and show it a report
able to get report but showing in single column if i take a printout paper will be wasted so I thought of passing these values to two different columns
please help me in giving some suggestionsIn Oracle 9 you can get rid of the regex functions and use traditional SUBSTR, INSTR and REPLACE:
ABSOLUTELY NOT TESTED...
SELECT col1,SUBSTR ( ','||col2||',', instr(','||col2||',',',',lvl)+1,instr(','||col2||',',',',lvl+1)-instr(','||col2||',',',',lvl)-1)
FROM table_name,
(SELECT LEVEL lvl
FROM (SELECT MAX (LENGTH (REPLACE ( col2, ',',''))) mx
FROM table_name)
CONNECT BY LEVEL <= mx + 1)
WHERE lvl - 1 <= LENGTH (REPLACE ( col2, ',',''));Max -
Split one column value into two columns using t-sql
Hi All,
I have one varchar column in a table.
Col1
ABC-12C4
BC-A345
CD
XYZ
How to split this into two columns like this using t-sql
Col1 Col2
ABC 12C4
BC A345
CD
XYZ
Thanks,
RH
sqlassuming a static delimiter, and the split will end up with a max of 2 columns, something like this would work. basically you just need to determine where the delimiter is, and then use the left and right functions to find the 2 pieces.
declare @t table(value varchar(10))
insert into @t(value)
values
('ABC-12C4'), ('BC-A345'), ('CD'), ('XYZ')
select
case
when charindex('-', value) != 0 then left(value, charindex('-', value) - 1)
else value
end as col1,
case
when charindex('-', value) != 0 then right(value, len(value) - charindex('-', value))
else ''
end as col2
from @t -
K-Bits (1) : Interchange the values of two columns
Hi Everyone
I wanted to get started a mechanism of knowledge sharing in the way of a series of threads called “K-Bits” (Knowledge Bits).
In our day to day work, we learn some new things which can be useful for others. However we hardly get a chance to share it with others.
Here is the opportunity to share your knowledge in the form of “K-Bits”.
Here we start with the First Tip of this series.
You might face a situation where you need to interchange the values of 2 columns in an Oracle database table.
E.g. there is a table employee having columns EMPID, FIRST_NAME, LAST_NAME and SALARY. By mistake the values of FIRST_NAME and LAST_NAME have been interchanged. Now you need to bring the data in correct state.
You can think about following few options:
Option-1_
1. Alter table employee and add a new column TEMP_NAME to it.
2. Update the values of LAST_NAME to TEMP_NAME.
3. Update the LAST_NAME with the values of FIRST_NAME.
4. Update the FIRST_NAME with the values of TEMP_NAME.
5. Drop the column TEMP_NAME.
Option-2 (For Oracle version 9i or higher)_
1. Alter table employee and rename LAST_NAME column to TEMP_NAME.
2. Alter table employee and rename column FIRST_NAME to LAST_NAME.
3. Alter table employee and rename column TEMP_NAME to FIRST_NAME.
Probably you can go ahead with any other solution as well. However there is one very simple solution.
Option-3_
Let do it by example:
DROP TABLE EMPLOYEE;
CREATE TBALE EMPLOYEE
EMPID NUMBER
,FIRST_NAME VARCHAR2(30)
,LAST_NAME VARCHAR2(30)
,SALARY NUMBER
INSERT INTO EMPLOYEE VALUES (1,'Tendulkar','Sachin', 10000);
INSERT INTO EMPLOYEE VALUES (1,'Ganguli','Saurabh', 10000);
INSERT INTO EMPLOYEE VALUES (1,'Pathan','Irfan', 10000);
INSERT INTO EMPLOYEE VALUES (1,'Khan','Jaheer', 10000);
INSERT INTO EMPLOYEE VALUES (1,'Agarkar','Ajit', 10000);
INSERT INTO EMPLOYEE VALUES (1,'Dravid','Rahul', 10000);
SELECT *
FROM EMPLOYEE;
UPDATE EMPLOYEE
SET FIRST_NAME = LAST_NAME
,LAST_NAME = FIRST_NAME;
SELECT *
FROM EMPLOYEE; The update statement above solves the purpose. Is not it simple? But how does it work??
For any DML (Insert, Update or Delete) oracle internally fires the row level triggers. You can read more about triggers at
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96524/c18trigs.htm
and
http://download-east.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg13trg.htm#431
As you know in row level triggers the values of each column is stored in :OLD and :NEW parameters. For the above UPDATE statement oracle stores the old values of FIRAT_NAME and LAST_NAME in :OLD.FIRST_NAME and :OLD.LAST_NAME parameters respectively and then update FIRST_NAME with :OLD.LAST_NAME and LAST_NAME with :OLD.FIRST_NAME.
Regards
Arun Kumar GuptaFor any DML (Insert, Update or Delete) oracle internally fires the row level triggers.Any pointer to the documentation supporting this ?
Edited by: Saubhik on Dec 7, 2010 5:58 PM -
How to Identify mismatch values in two columns
I have two tables basically two excel files used by two different depts. I am trying to reconcile dollar amounts between two.
Table A has ID, Amount,Paid Date
Table B has ID,Amount ,Paid Date.
What`s happening is between two tables at times we are finding amount column values differ for same paiddate, there are instances where same transaction recorded in table A will have a different amount but Paid Date will be different. I am trying to find
ID`s which have different amounts.Code below I am trying to find ID`s that exist in both tables and In my where clause I am using where Amount col from Table A is not equal Amount Col in Table B. When I run this code I get I dont see mismatched amounts
select l.id,SUM(l.[amount]),a.amount
FROM SFY14_Detail_Q1 a
inner JOIN dbo.Qtr1_X_Recon l ON l.[id] = a.ID
WHERE l.[amount] <> a.amount and l.[amount] <> 0
group by l.id,a.amount
order by sum(l.[amount]) desc
FMChances are, it's because you are grouping by amount. If you look closer, you'll probably see the same ID twice, once for one amount, and again elsewhere for the other amount. So by appearing twice, your query is working, it is identifying
the two with different values, but grouping by Amount, you're not seeing them side by side. You could sort by ID instead, then amount, then they'll show twice, near one another. -
How to concatinate values of two columns and update into another column
There is a table : TEST contains three columns - Column1 , Column2 , Column 3
Column1 contains values - (1,2,4)
Column2 contains values : (a,b,c)
Column 3 is empty .
Target : Values in column 3 should be (1a,2b,4c)
Need to achieve this through procedure .Paul if i want to concatenate two strings or alpha numeric characters from 2 fields and display in the third field,Will this code be able to do that?
-
Query help needed in finding max value between two columns
I have a table as follows:
-- INSERTING into TESTTABLE
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('A','4.5','AA',0.3,'AB',5.5);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('B','1','BB',2.5,'BC',6.9);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('C','2.6','CC',3.3,'CD',1.4);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('D','1.8','DD',2.9,'DE',1.2);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('E','6.8','EE',4.8,'EF',9.6);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('F','2.0','FF',6.34,'FG',3.9);
Insert into TESTTABLE (COLA,COL2,COLC,COLD,COLE,COLF) values ('G','1.7','GG',3.6,'GH',5.8);
I want to get results as follows:
COLA COL2 MaxCol MaxColVal
A 4.5 AB 5.5
B 1 BC 6.9
C 2.6 CC 3.3
D 1.8 DD 2.9
E 6.8 EF 9.6
F 2.0 FF 6.34
G 1.7 GH 5.8I want to get the max value of either of the columns COLD or COLF.. Whichever column has got max value, then the corresponding value of COLC and COLE should be returned..
For eg., in first row, COLF has higher value than COLD.. ie., COLF = 5.5 > COLD = 0.3, so for row1, i want the result as MaxCol is AB and MaxColvalue is 5.5..
Similarly for third row, COLD =3.3 > COLF=1.4, so for 3rd row, i want the result as MaxCol is CC and MaxColvalue is 3.3
How is it possible to do this in a qery? Any help.. please..SQL> select cola
2 , col2
3 , case greatest(cold,colf)
4 when cold then colc
5 else cole
6 end maxcol
7 , greatest(cold,colf) maxcolval
8 from testtable
9 /
C COL MA MAXCOLVAL
A 4.5 AB 5,5
B 1 BC 6,9
C 2.6 CC 3,3
D 1.8 DD 2,9
E 6.8 EF 9,6
F 2.0 FF 6,34
G 1.7 GH 5,8
7 rijen zijn geselecteerd.Regards,
Rob. -
Comparing substr values of two columns
Say you have a table with 3 columns:
*Unique random-generated id,
*First name
*Mailing name
I need to find all the rows where the mailing name does not contain the value of the first name column.
The "like" operator (only used with where clause) doesn't seem to work because what you want to do is:
select * from table
where [first_name is *not* found in *part of* (it will never be exact match) the mailing_name]
What's the correct where clause?
Any help is appreciated. ThanksMaybe You can use something like
select * from table
where instr(Mailing name, First name) = 0
For example
SQL> select 1 from dual
2 where instr('GINTS PLIVNA','aaa') = 0;
1
1
SQL> select 1 from dual
2 where instr('GINTS PLIVNA', 'INTS') =0;
no rows selected
SQL> -
Adding the value of two columns and place to 3rd column in jtable
hi all,
i have table with 3 columns with rows
say for example --loan, interest, total
i want add loan+interest and place into total column.
how can i do this?
thanks in advance
dayaUse a TableModelListener:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=566133 -
Compare two columns and match ALL recurring values, not just the first instance
Hi everybody...
I was looking for a way to compare values in two columns, identifying every duplicate value instance on a third column.
Searching around the forums, I found a solution, albeit a partial one; I am using this formula: =IFERROR("Duplicate in row "&MATCH($A,$B,0),"") along column C, to compare values between columns A and B. When applied, the formula will render the first instance where there is a duplicate; unfortunately MATCH will only register the first instance of the duplicated values.
For example:
The first value on column A is 'Apple'. On column B there are three instances for the value 'Apple', the formula identifies the first of these values, but not the remaining two.
I am not an advanced Numbers or Excel user, and the answer to this problem eludes me. I am attempting to compare columns that have no less than 1000 rows each, so you can imagine how, finding a solution to my problem would be really great.
Thanks in advance,
PabloUnfortunately I can't see your screenshot, but supposing you have a table like this:
Col1
Col2
1
3
Dupe
2
4
Dupe
3
5
Dupe
4
6
5
7
Then here is one way to flag the duplicates.
The formula in C2, copied down, is:
=IF(COUNTIF($A,$B2)≥1,"Dupe","")
Then filter on column C for 'Dupe', and copy the values in column B to wherever you need them.
SG
Maybe you are looking for
-
Mac Mini wont connect to the internet both wired or wifi! Any help?
My other two Macbooks will connect to the net both wired and wifi. As of this morning my Mac Mini just stopped connecting all together. I have version 10.6.8. I only really use the Mac Mini to browse the web and watch movies off of my external hard d
-
Mq3_6-plt-win.zip seems to be corrupt
Hi, I am trying to install the latest Sun Java System Message Queue 3 2005Q1 Platform Edition on Windows XP. The installation crashes with complaining about a missing JaxRPC.cab. A brief check confirms it does not exist in the zip file. Any help? Tha
-
macbook pro 4GB S N w80500ox3atp i wont to clean the mac-keeper dos not install
-
Does anyone know how to set the CWIMAQViewer Palette to binary using C++? I know how to do it in Visual Basic, but I can't figure it out in C++. I need to do it programatically. Thanks in advance.
-
Selection-options on a module pool screen
Hi all, How to define a field as selection-options on a module pool screen. Thanks, Chuong