How to compare two columns
Hi friendsI have a requirement
I have a table with 4 columns in that two columns starttime and endtime
for Ex: starttime is 11/30/2010, 3:02:45 and endtime is 11/30/2010, 3:23:28
I want to add two condition is
(1) the starttime and endtime must be on the same date for EX: if the starttime is 30 means the end time must also be 30, but the duration may vary
(2) the endtime not null
How can I write a query for this
Please guide me
Thanks in advance
Beatrice
Try this query
Select * from your_table
When trunc (starttime) = trunc (endtime)
and enddate is not null;
/
Tags: Database
Similar Questions
-
How to compare two columns in Xl
I want to compare two columns in the file of Xl. column A contains phrases and column B contains the words
For example
Column A Column B Column C
I have an Apple and I'll eat every day Apple Apple
I have a banana and eat weekly banana papaya
Oranges are rich in nutritions cauliflowers Oranges
Papaya is good for health Grapes Papaya
Oranges
Lichi
Banana
I want to check each value of column B in each cell in column A, and if it matches then it should return the corresponding value in the result to me. Column C should Look Like as shown above.
Can someone point me in the right direction here of what formula to use for this Xl.
Thank you
This is a forum for Mac OS X technologies, so here's an Applescript solution:
- Copy-paste the script in the Script Editor
- Select the cells in columns A and B
- Command + c to copy to the Clipboard
- Click on the button "run" in the Script Editor
- Click once in the top cell in column C where you want the data
- Command + v to paste
Here are the results:
There is no verification error here. You must select and copy to the Clipboard before the race.
SG
the value LstOfLsts to makeListOfLists (the Clipboard as a 'class utf8 ')
the value theSentences to getCol1Vals (LstOfLsts)
the value collected in getCol2Vals (LstOfLsts)
game of theMatches to «»
Repeat with I in collected items
If theSentences contains I then ¬
the value of theMatches to theMatches & i & return
end Repeat
Set the Clipboard for theMatches
to getCol1Vals (LofL)
game of col1Vals to «»
Repeat with en LofL points
the value col1Vals to the col1Vals & "" & i point 1
end Repeat
end getCol1Vals
to getCol2Vals (LofL)
the value col2Vals to {}
Repeat with en LofL points
If i's point 2 is not "" then ¬
i copy point 2 to the end of col2Vals
end Repeat
return col2Vals
end getCol2Vals
at makeListOfLists (theTxt)
value was to theTxt paragraphs
the value text point of delimiters
the value theListOfLists to {}
Repeat with I from 1 to count was
the value theListOfLists to the theListOfLists & {the was point i text elements}
end Repeat
the value point text delimiters to «»
return theListOfLists
end makeListOfLists
-
How to compare two columns in OBIEE?
Hello
I have two columns like "abc" and "def". I want to display only the rows where the value of 'def' is greater than the value of 'abc '. How to perform in the analysis? How to use the operator for comparison for the columns in the analysis?Try this:
Criteria-> column-> Filter tab-> Advanced-> 'Convert this SQL filter' and the two columns with condition.Appreciate if you mark as correct
Published by: Srini VIEREN on 23 January 2013 06:58
-
target table (emp_target)source(emp) ----- ename d_ename -------------------------- john john chris joe mary mary
--------------------------
f_ename - must fill in the value function ename and d_ename. compare two columns if the column is null, then take the column which is not null. If the two columns are populated then take all of the column. It will have the same values.
Please help me how can I have f_ename value in the emp_target table.
compare two columnsexpected output f_name ----- john chris joe mary
and take what is not nullHello
Nordine Show, you can use NVL, or the function COALESCE sometimes more fast.
If you are filling out the table emp_target with the values of the emp table, then you can use NVL (or COALESCE) in an INSERT statement like this:
INSERT INTO emp_target (f_name) SELECT COALESCE (ename, d_ename) FROM emp ;
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask a DML statement, such as INSERT, sample data will be the content of the or the tables before the DML, and the results will be the State of the or a modified tables when it's all over.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002} -
How to compare two lines in PL/SQL?
Hi all
How to compare two lines in PL/SQL? Is there a method I can use to compare their column by column instead?
Any comments would be much appreciated.PhoenixBai wrote:
By lines I mean, two rows of the same table!Ah, finally, we get a bit more useful information
and I need to compare the column by column to see if there is a difference between these two rows.
Like this, you mean?
SQL> ed Wrote file afiedt.buf 1 with data as (select 1 as id, 'A' as dta, 'B' as dta2 from dual union all 2 select 2, 'A', 'B' from dual union all 3 select 3, 'B', 'C' from dual) 4 -- 5 ,chk as (select &id1 as id1, &id2 as id2 from dual) 6 -- 7 select case when ( 8 select count(*) 9 from ( 10 select dta, dta2 11 from data, chk 12 where id = id1 13 minus 14 select dta, dta2 15 from data, chk 16 where id = id2 17 ) 18 ) = 0 then 'No Difference' 19 else 'Difference' 20 end as check_result 21* from dual SQL> / Enter value for id1: 1 Enter value for id2: 2 old 5: ,chk as (select &id1 as id1, &id2 as id2 from dual) new 5: ,chk as (select 1 as id1, 2 as id2 from dual) CHECK_RESULT ------------- No Difference SQL> / Enter value for id1: 1 Enter value for id2: 3 old 5: ,chk as (select &id1 as id1, &id2 as id2 from dual) new 5: ,chk as (select 1 as id1, 3 as id2 from dual) CHECK_RESULT ------------- Difference SQL>
My only concern is the result of this sql. East - reliable? It can really be used to differentiate the two lines? I mean, the result would be the same, as I do with Java?
Not sure what you mean by "reliable"? SQL is not some kind of generator of random result (by derogation from the use of the DBMS_RANDOM package). If you ask him if 1 + 1 = 2, then it will always give you the right answer.
-
How to compare two dates and find exactly
How to compare two dates and find the exact age of the person, no one could be an age of child 2 days or a month, or other.
I'd really appreciate if someone help o
Concerning
After spending 2 hours, I go out with a solution by myself, how ever the function can be customize to check if the user enters date right.
function findAge(subjectName,fromdate, todate) { console.log("findAge(fromdate, todate) is called now "+subjectName+"-->"+fromdate+"-->"+todate); if(todate) todate= new Date(todate); else todate= new Date(); var age= [], fromdate= new Date(fromdate), y= [todate.getFullYear(), fromdate.getFullYear()], ydiff= y[0]-y[1], m= [todate.getMonth(), fromdate.getMonth()], mdiff= m[0]-m[1], d= [todate.getDate(), fromdate.getDate()], ddiff= d[0]-d[1]; if(mdiff < 0 || (mdiff=== 0 && ddiff<0))--ydiff; if(mdiff<0) mdiff+= 11; if(ddiff<0){ fromdate.setMonth(m[1]+1, 0); ddiff= fromdate.getDate()-d[1]+d[0]; --mdiff; } if(ydiff> 0) age.push(ydiff+ ' year'+(ydiff> 1? 's ':' ')); if(mdiff> 0) age.push(mdiff+ ' month'+(mdiff> 1? 's':'')); if(ddiff> 0) age.push(ddiff+ ' day'+(ddiff> 1? 's':'')); if(age.length>1) age.splice(age.length-1,0,' and '); console.log("==============================="); console.log("Subject age is = "+age.join('')); console.log(" age Day = "+ddiff); console.log(" age Month = "+mdiff); console.log(" age Year = "+ydiff); console.log("==============================="); var subjectAGE = age.join(''); }
peardox Thanks for the reply
-
How to compare two files to see the differences in the content?
How to compare two files (one word and a single pdf) to see if the files are identical without having read all 7 pages?
Thank you
You cannot compare files of different nature. If you convert the Word file to PDF, you can then compare the two files in Acrobat.
-
Oracle how to multiply two columns of different tables and results
Oracle how to multiply two columns of different tables and get the result in the third column?
I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D
Edited by: 994229 2013-03-15 12:44/* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */ CREATE TABLE mytable1 AS (SELECT 1 id, 5 VALUE FROM DUAL UNION ALL SELECT 2, 7 FROM DUAL UNION ALL SELECT 3, 8 FROM DUAL); CREATE TABLE mytable2 AS (SELECT 1 id, 4 VALUE FROM DUAL UNION ALL SELECT 2, 12 FROM DUAL UNION ALL SELECT 10, 12 FROM DUAL); SELECT id, mytable1.VALUE, mytable2.VALUE, mytable1.VALUE * mytable2.VALUE product FROM mytable1 FULL OUTER JOIN mytable2 USING (id) ORDER BY id;
ID VALUE VALUE_1 PRODUCT 1 5 4 20 2 7 12 84 3 8 10 12
-
can anyone tell how to compare two documents with two controlled with the same mouse pointers
can anyone tell how to compare two documents with two controlled with the same mouse pointers?
Windows and OS X can only display a mouse pointer - it is created by the operating system, not the application.
-
[8i &; 10g XE] How to compare a column with the text of a column with numbers
This is probably a simple question, but I can't seem to find the answer. I tried variations on use to_number to_char and interpreters, all nothing will do.
The real problem is that I have a table with a column of numbers in a database 8i (datatype = NUMBER (3)) and a column with the text (datatype = CHAR (3)), and I need to compare two values.
This table has thousands of lines, but here's an example of the data in these two columns:
What I want to do is select the lines where the TXT and CHR VALUES do not match, then it would be (given my example):TXT CHR ----------- 001 1 001 2 002 2 XXX 1 003 3
But, I'm having difficulties in comparing two columns, because they are not the same type of data.TXT CHR ----------- 001 2 XXX 1
I tried to work on a simplified version of the problem in the 8i database both my 10g XE database:
But this also returns any line, and it isn't even the "XXX" in the text column to treat in this example.SELECT * FROM ( SELECT 1.000 AS nbr , TO_CHAR(1.000,'000') AS txt , CAST('001' AS CHAR(3)) AS chr FROM dual ) WHERE txt = chr ;
Can someone help me understand what it is that I'm missing?
Thank you!Hello
user11033437 wrote:
This is probably a simple question...Simple if you know the secret; maddening if you do not have.
... I tried to work on a simplified version of the problem in the 8i database both my 10g XE database:
SELECT * FROM ( SELECT 1.000 AS nbr , TO_CHAR(1.000,'000') AS txt , CAST('001' AS CHAR(3)) AS chr FROM dual ) WHERE txt = chr ;
Try:
TO_CHAR (1.000, 'FM000')
By default, TO_CHAR leaves place the beginning of the string to a sign less, in which case he should ever one, TO_CHAR (1,000, '000') returns makes 4 characters, not 3. "FM" in the format said TO_CHAR do not add a space.
If it does not, after the release of DUMP (txt) for the few lines that you can't match, so that we can see exactly what is in them.
-
How to compare two fields in two separate databases
Hello
Can we compare two columns in two separate databases with a single script.
See you soon
SexyHello
If you mean Oracle to SQL Server while you'd have to put the hand in the Pocket and buy ODBC connectivity for this...
If it's just one large may export your data and import into an Oracle table and make your unique comparison.
Kind regards
Robert.
-
How to compare two different backgrounds
Can one tell me please how to compare two circles as DEVL test?
I don't know how to compare a project (like DEVL test) but I want to see all the changes in all the objects between two different backgrounds.
Please help me.
Thank you.use AppDesigner, navigate to tools / compare and report / database
The target DB access code,
Press Options
comparison of Goto tab options & select compare Type = database -
ViewCriteria comparing two columns of the table to create
Anyone know how I can create a ViewCriteria where clause that compares the two columns of the same table?
For example if I had two columns of integers (MINSAL and MAXSAL) and wanted to see if they are equal. Normally, I would do the following SQL below.
SELECT * EMPL
WHERE MINSAL = MAXSALTry to link any of them to an expression of groovy.
Timo
-
Compare two columns and get the percentage of cells that match
Hello
I'm looking to take two columns of data from different tables in the same document, which should have a high enough percentage of boxes and have another cell tabulate the corresponding percentage. I can the of seem to figure out how to do this, but it seems really possible.
Any help is greatly appreciated.
Thank you!
C1 = A1 = B1
It's shorthand dethrone select cell C1 and type (or copy and paste it here) the formula:
= A1 = B1
Select cell C1, copy
Select the column C, paste
Select cell E2, and then type 'TRUE '.
Select cell E3 and then type "FALSE".
F2 = COUNTIF ($C, E2)
F3 = COUNTIF ($C, E3)
G2 = F2÷SUM(F$2:F$3)
G3 = F3÷SUM(F$2:F$3)
-
How to compare two files in Windows 7 prof 64 bit
I have two files which has several files. I would like to compare the two files and see which folder has more files, and what are their names? How I do that in Windows 7 prof 64 bit? Is useful that I can download?
Hey dude-
Here's the right way to do without external downloads. It looks like a lot at first, but once you have done so, it is very easy. It works in all versions of Windows 7 to 95. For our example, let's assume you're to compare two directories named 'A' and 'B '.
1. run cmd.exe to get a command prompt. (In Windows 7, the powershell will not work for this, FYI.) Then do it again, so that you have two of them opened next to each other.
2. in each window go into the directories you want to compare. (With the help of the 'cd' command. If you're not comfortable with that, then you should probably go with the external utilities, except if you want to learn the tricks of the command prompt.)
3. type ' dir/b > A.txt' in one window and "dir/b > B.txt' in the other." Now you have two text files that list the contents of each directory. The flag/b means stripped, which removes the list down to only the names of files directories.
4. move is the same folder as A.txt B.txt.
5. Type "CF A.txt B.txt". The command "CF" means file to compare. It will spit out a list of the differences between the two files, with an additional line of text above and below each difference, so that you know where they are. For more options on the way in which the output is in the format, type ' fc /? "at the command prompt. You can also pipe the differences in another file using something like ' CF A.txt B.txt > differences.txt'.
Have fun.
Maybe you are looking for
-
Hi, I noticed for the upgrade of iphone6 that now when I get a missed call that does not appear in the call logging so I have no idea its been missed. How can I get this working again?
-
Thunderbird does not work after installing Win 10 and the mobile profile of Win 7
I've installed Tbird 38.3.0 on a new Dell computer with Windows 10 on this (8 GB of RAM, 1 TB harddrive). I then followed these steps to put my old profile from the old computer to Windows 7:1. copied my profile on the Windows 7 computer on an extern
-
HDMI / projector with Satellite L50-B-2FN problem
Hello! HDMI / projector with my brand new Toshiba problem. My computer laptop hdmi works fine with my tv Samsung, no problem. I simply press F4 and select how I want my second screen action on my tv.But when I connect my laptop to my Optoma HD67 proj
-
How to allow https in the filtering list
I use the function 'only green list' and it works well, except how do you add an https site to your allowed sites list? The entry of URL allowed type field is automatically the prefix http and does not give you the option to use the https protocol.
-
How do I uninstall "windows powershell".
Recently had to replace the drive hard and now want to re - install using the disc to "Reinstall". Through windows its asking to uninstall "powershell" to proceed. Sorry but I have no idea what to do because its not in Add/Remove Programs list... HEL