How to count the continuous dates in oracle 11g
HelloI need to count the continuous more than 9 days between given dates below is my example
Are my data like this
MAY 1, 2013
MAY 2, 2013
MAY 3, 2013
MAY 4, 2013
MAY 5, 2013
6 MAY 2013
MAY 7, 2013
MAY 8, 2013
MAY 9, 2013
MAY 10, 2013
Now I want the number of days between these continuous days of more than 9 days now, I will get the result for the above data is 10 days
If any date is not in the list then days would not result if it is less, then are equal to 9 days
Here is an example of another
MAY 1, 2013
MAY 2, 2013
MAY 3, 2013
MAY 4, 2013
MAY 5, 2013
6 MAY 2013
MAY 7, 2013
MAY 8, 2013
MAY 10, 2013
11 MAY 2013
number of days here is 10 but may 9, 2013 is away at the moment, the county should not show as 10 because continuous date (May 9, 2013) is absent, that's what I need, please suggest the solution.
using the {: identifier of the thread = 1005478}
SQL> ed
Wrote file afiedt.buf
1 with test as
2 (
3 select date '2013-5-1' dt from dual union all
4 select date '2013-5-2' dt from dual union all
5 select date '2013-5-3' dt from dual union all
6 select date '2013-5-4' dt from dual union all
7 select date '2013-5-5' dt from dual union all
8 select date '2013-5-6' dt from dual union all
9 select date '2013-5-7' dt from dual union all
10 select date '2013-5-8' dt from dual union all
11 select date '2013-5-9' dt from dual union all
12 select date '2013-5-10' dt from dual union all
13 select date '2013-5-11' dt from dual union all
14 select date '2013-5-13' dt from dual union all
15 select date '2013-5-14' dt from dual union all
16 select date '2013-5-15' dt from dual union all
17 select date '2013-5-16' dt from dual union all
18 select date '2013-5-17' dt from dual
19 )
20 select min(dt),max(dt),count(*)
21 from (select dt,
22 dt-Row_Number() over(order by dt)
23 as disTance
24 from test)
25 group by disTance
26* order by min(dt)
SQL> /
MIN(DT) MAX(DT) COUNT(*)
--------- --------- ----------
01-MAY-13 11-MAY-13 11
13-MAY-13 17-MAY-13 5
Tags: Database
Similar Questions
-
How to create the new database in oracle 11g
Hello
I m new in oracle 11g, I downloaded oracle 11g and with the help of the guide of the developer-2 days, I learned all the SQL queries, but I worked with human resources database.
Now, I want to create my own database with the required tables. Can anyone help me how I can make my own database in oracle 11g.
Thank you
Manna870692 wrote:
Hello
I m new in oracle 11g, I downloaded oracle 11g and with the help of the guide of the developer-2 days, I learned all the SQL queries, but I worked with human resources database.
Now, I want to create my own database with the required tables. Can anyone help me how I can make my own database in oracle 11g.Thank you
MannaBe sure to distinguish between the terms and the database schema. Other products, make them bad. It would be a HR diagram (or a user, which is the same in Oracle). If you do not need to use the database Wizard, unless you are working with a new host with no database.
A simple way would be to get the DDL to create the HR schema and modify it for your own. It can be extracted from your database in several ways, or you can copy the hr_cre.sql to your own script and change. The two ways are educational, and you can google for instructions.
-
How to purge the sales data in Oracle Demantra
Hi experts Demantra,
I have a doubt in demantra:
Assume that the user has loaded historical data say data sales history of table SALES_DATA.
And after using the Analaytical engine, forecasts were generated as well.
Later, he found that it was a bad data and now it should be removed.
If the user wants to remoe these records in the SALES_DATA table.
What is the process of purging the records?
Thank you
Neeraj.Hello
Have you checked Note: 467748.1 (which is referenced in the comment above)?
I've never used this procedure before, but according to the DATA_CLEANUP.clean_level_data can be used to clean the data in the SALES_DATA table.
Kind regards
Hussein -
How to find the SID for DB Oracle 11g
Someone installed a new database of Oracle 11 g on my machine. Now I'm opening "SQL Developer" and it asks username, password and sid. I don't know what is the SID for my case. How I know that?
2827706 wrote:
The guy is not available.
I checked the list of services in my machine. There is no service windows in my system named OracleService
You mention that you are using Windows, but if you are and that you have installed the oracle database software and NO service like OracleService
, then you do not have a database. But then, why the hell you you ask about this? If you do not want the database software, why don't you just go ahead and uninstall it? And how is it, someone can come and something on your server and have no idea about it? Aman...
-
How to count the number of elements in a data block
Hi all
How to count the number of elements in a particular data block oracle Forms 10g.
If it's a text_item or the display_item or the list_item etc is there any method to do this.
Please answer...get the first element with GET_BLCOK_PROPERTY(..., FIRST_ITEM);
loop until GET_ITEM_PROPERTY(..., NEXTITEM) is null
count on in the loop. -
How to count the number of columns in an oracle table using sql
How to count the number of columns in an oracle table using sqlYou must put the name of the table in capital letters
As
SELECT COUNT(1) FROM user_tab_columns WHERE table_name = 'EMP'; or SELECT COUNT(1) FROM user_tab_columns WHERE table_name = UPPER('Emp');
Concerning
Arun -
How to count the number of data records?
Hey guys, how to count the number of records, I had on a data object variable?
Im having a result of sql query in a variable like this:
oDB.resolveNode("#command").query.select.value = "SELECT * FROM Customers WHERE CliNombre LIKE ' % ' + input1 +" %' ";
oDB.open ();
oDB.first ();
So I need to count the number of records retrieved by this SQL query at the moment. Help please
Then move the cursor back to the first record after you have your account.
There is a keyword count in SQL that will allow you to get the account of your request. You can run that first - get your account, and then run the actual query to get the Recordset. This would require a separate data connection. Some examples of code.
var xfa.event.newText = inName;
If (inName == "") {}
App.Alert ("you must enter a name--try again!")
}
var nIndex = 0;
While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection2")
{
nIndex ++;
}oDB = xfa.sourceSet.nodes.item (nIndex) .racing var (1); pertaining to the specified data connection node
App.Alert (ODB.saveXML ("Pretty"));var nIndex = 0;
While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection3")
{
nIndex ++;
}
var oDBCount = xfa.sourceSet.nodes.item (nIndex) .racing (1); pertaining to the specified data connection node
Configure sql call DB to get the number of records that match the criteriaoDBCount.nodes.item (1).query.setAttribute ("text", "commandType");
oDBCount.nodes.item (1).query.select.nodes.item (0) .value = "Select count (*) from table1 where AcctNumber = '" + inName + "'";
oDBCount.open)
oDBCount.close)Configure sql call DB to get the specified employee number
oDB.nodes.item (1).query.setAttribute ("text", "commandType");
oDB.nodes.item (1).query.select.nodes.item (0) .value = "Select * from table1 where AcctNumber = '" + inName + "'";
App.Alert (ODB. Nodes.Item (1) .saveXML ("Pretty"));now connect to the DB and get a recording
oDB.open)
oDB.close ();Note the SQL command use the keyword count (take a look at the oDBCount section). This will return a number of return to the cllaer. When I set up the data connection, a node count (*) that appeared there. I dragged to the form and it has created a field called count that the onus at this node. When the query is executed, the number of resulting records returns to this field. You can have hidden it so that your users can not see it and also to change the binding votes to zero, so it is not included in the data file that is submitted when the form is complete.
Paul
-
How to count the number or lines in the file
Hi Experts,
I'm file as source and Oracle as target. My folder that contains some data that will load the target.
My requirement is that I want to count the number of lines that contains my folder. Please help me how to count the total number of lines in the file.
THX,
Sara.Hi Sahaveda,
Now, I tried and it works.
Sorry my mistake again.
I created HR. ETL_FILE_LOG as below:
CREATE THE TABLE HR. ETL_FILE_LOG (numero_fichier varchar2 (10))
Below the code will run without error:
import java.lang as lang
import java.sql SQL
import of java.lang.String
Import os
disadvantages is sql. DriverManager.getConnection ("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")
dblinks = cons.createStatement)
File1 = Open ('c:\EMP.txt','r')
Count = 0
Line = file1. ReadLine()
all online! ='' :
Count += 1
Line = file1. ReadLine()
File1. Close()
sqlQuery = "insert into HR. "The values of ETL_FILE_LOG (numero_fichier) (" + str (count) + ' ") '.
rqQuery = dblinks.execute (sqlQuery)
jerks. Close()
Concerning
-
I use Windows XP Home Edition and I am fully up to date with the latest version of the software.
I would like to activate my mouse USB power out "sleep mode" on my computer. I found the help topic that describes how to do this: http://support.microsoft.com/kb/280108 how to enable the continuation of the Standby Option for a USB mouse
However, when I follow these steps, I don't see the 'allow this device to wake the system from standby mode ' check box on any of the windows as described in the documentation for Ms.
I use a Microsoft Comfort Optical Mouse 3000 (IntelliPoint) USBAny help would be greatly appreciated!
This gives a test:
1. click on START
2. click on 'run '.
3 type "notepad" (without the quotes) and press enter
4. copy and paste this into Notepad:Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usb]
"USBBIOSHACKS" = DWORD: 00000000
"USBBIOSx" = DWORD: 000000005. click on file > save as
6. change the dropdown to "all files".
7 type usb.reg as the file name and save the file somewhere easy to access
8 go find the file and double click it. Confirm that you want to add it to the registry
9 restart the computer and see if you can wake the system from standby modeFor reference, take a look at this:
http://www.dslreports.com/Forum/r19635912-missing-power-management-tabLet us know,
Thank you!
Ryan Thieman
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
How to count the number of hit on the page, click
Hello..
can someone tell me...
How to count the number of hit on the page, click
Thanks in anticipation...Somethig like that?
http://www.baigzeeshan.com/2011/12/Oracle-ADF-storing-temporary-values-in.html -
How to count the number of nodes under each parent in any given xml
How to count the number of nodes under each parent in any given xml. for example the xml below was
books has 3 childern, library [1] has 4, [2] library has 6 and bookshop [3] has 2. is it possible to get the number of tags in a childnode duplicate IE library [1]
Book1 Tagus repeated twice... vice versa. do we need to make plsql lie we can achieve through sql
< book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
ACR < book1 > < / book1 >
Lac < Book4 > < / Book4 >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
ACR < book3 > < / book3 >
ACR < book3 > < / book3 >
tray of < bookn_1 > < / bookn_1 >
adjusted cost base < bookn > < / bookn >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
< / book >
< / books >
I tried this... query.
Select
XMLQUERY ('count($doc/Books/Bookstore[1]/descendant::*)' in the way of xmltype ("< books >
< library >
ABC < book1 > < / book1 >
ACR < book1 > < / book1 >
Lac < Book4 > < / Book4 >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
< / book >
(< / books > ')
as 'doc' of happy return) .getNumberVal () as node_count
of the double
Select
XMLQUERY ('count($doc/Books/descendant::*)' in the way of xmltype ("< books >
< library >
ABC < book1 > < / book1 >
ACR < book1 > < / book1 >
Lac < Book4 > < / Book4 >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
< / book >
(< / books > ')
as 'doc' of happy return) .getNumberVal () as node_count
of the double
How can I get the counts for each parent in a single query
Published by: user7955917 on August 24, 2012 07:26Generic function how you want the query to be.
If the structure is known in advance, as in your example a 'books' and then a 'library' root element, it's as simple as:
SQL> select x1.parent_id, x2.child_name, count(*) 2 from tmp_xml t 3 , xmltable( 4 '/books/bookstore' 5 passing t.object_value 6 columns parent_id for ordinality 7 , child_list xmltype path '*' 8 ) x1 9 , xmltable( 10 '/*' 11 passing x1.child_list 12 columns child_name varchar2(30) path 'name()' 13 ) x2 14 group by x1.parent_id, x2.child_name 15 order by x1.parent_id, x2.child_name 16 ; PARENT_ID CHILD_NAME COUNT(*) ---------- ------------------------------ ---------- 1 book1 2 1 book2 1 1 book4 1 2 bookn 1 2 bookn_1 1 2 book1 1 2 book2 1 2 book3 2 3 book1 1 3 book2 1 10 rows selected
If you want a generic solution that works without knowledge of the structure, you will need a recursive approach, and most importantly, you should know which nodes in distinct, I suppose that the leafs?
Also, please help if you can provide the link of reference on the function name() years what are the other expression, that I can use after the path
You can start reading the documentation: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_xquery.htm#CBAGCBGJ
The clause PATH expects a XQuery expression however before 11.2, we can put only simple XPath expressions.
-
How to normalize the gigantic data up to 3NF
Hello
How to normalize the gigantic data up to 3NF5 times the same question at the same time. This is not a task of the Oracle, it's main RDBMS design.
http://en.Wikipedia.org/wiki/Database_normalization
Werner
-
How to remove the extra space of oracle database column
How to remove the extra space of oracle database column. I would like to clean up the column in the database by deleting the extra space is entered by the dataentery people.
When I run the query:
SELECT
ROWID, C.CODETABLE_ID, C.CODEVALUE_ID, C.DESCR, LENGTH (C.CODEVALUE_ID).
C.OBSOLETE_DT, C.RECORDSOURCE, C.CREATED_DT,
C.CREATEDBY, C.LASTUPDATED_DT, C.LASTUPDATEDBY
OF CODEVALUE C
Where LENGTH (C.CODEVALUE_ID) > 6
the data type is varchar2 and I would get rid of the any extra blank space added to the column. in my case, if the length is greater than 6Hello
user452051 wrote:
Thanks for the reply. Why should I have this line?AND codevlaue_id! = TRIM (codevalue_id) - see note below
;I just changed my post when you posted this. The explanation is there now:
Frank Kulash wrote:
...
The condition "codevlaue_id!" = TRIM (codevalue_id)"does not change the results of everything, but it can make the most effective statement if there are lines where codevalue_id is on 6 characters long, but contains no additional space. It will prevent the triggers from firing and redo the data generated. -
How to check the manufacturing date of the Z3 Compact?
How to check the manufacturing date of the Z3 Compact?
Simple, pull on the flap of the IMEI and search for 14W__
The first 2 digits are for the year and the last 2 digits are the week
http://support.sonymobile.com/global-en/xperiaz3compact/Userguide/IMEI-number/
-
How to view the anticipated date of 3 days bb
Greetings
How to view the early date to 3 days with bb.
I was able to view the current in bb, but can not able to display the date fututre.
Help, please
concerning
Anthony singh
Hello
Add 3 days to the current date.
days3 long = (3 * 24 * 60 * 60 * 1000); MS
TimeFormat SimpleDateFormat = new SimpleDateFormat ("YYYY/MM/DD HH: mm: EEE");
timeString = «"+ timeFormat.formatLocal (System.currentTimeMillis () + Days3);»Thank you
Stephenson
Maybe you are looking for
-
Hello Sometimes when I connect my bluetooth headset for my macbook pro (El Capitan) I get a kernel panic error message and I have to restart the computer. It's very annoying. I'll post the stacktrace here in the case that a person is able to help me
-
I did a factory recovery using Recovery Manager on my desktop of windows 7 Home premium, Pavilion Elite 150ff. After having installed all the updates and download flash player and Adobe Reader and install my Antivirus HP Photo creations program won't
-
I have an Apple TV (2014) and I can't seem to set up a program on the NBC app. I signed up with all the necessary information on my iMac and it says: "your AppleTV is ready to use / you now have access to your favorite through the light House. But wh
-
Satellite A500 - fans never stops
Hello I did some experiments with methods of cooling of vista... First of all, when I start my satellite A500, something like three minutes before the fan to start very quickly.When I opened the Toshiba PC Health monitor, temperatures never exceed 40
-
age of empirs 3 the D3Dx9_25.DLL file missing
hope someone can understand it. 3 hours trying to solve this problem and im top. When I try to start the game the error message appears ip "is missing the D3D9_25.DLL file. I tried to download the update to fix, I tried the installation manual and th