How to add 2 dates in Oracle sp? [closed] - oracle

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How can we add two dates in oracle? For example in sql we can do this, " date_1 + date_2 " how can we achieve the same thing in Oracle

Adding two dates together would be meaningless but you can add an interval to a timestamp. For example, to add 1 year and 10 months to a timestamp:
SELECT SYSDATE + INTERVAL '1-10' YEAR TO MONTH FROM DUAL;
You can also add days to a DATE column using simple arithmetics. For example, you can add 45 days to the current date using:
SELECT CURRENT_DATE + 45 FROM DUAL;

Related

Sum and conditional in oracle sql [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Hello I need help on this query
I Have folliwing datas
Part OderQty ShippedQty QOH
10510 10 5 10
10510 10 0 10
10510 10 0 10
10511 10 10 20
10511 20 0 20
I need to filter where the sum of OrderQty - sum of Shipped Qty is < QOH.
Example:
Part 10510
total sum Ordered: 30
total sum Shipped: 5
Balance: 25
QOH: 10
I need all part where the condition is like part 10510
the second part number is fine because I needed 30, shipped 10 and have 20 on hand, do you how to write this query for oracle,
Thanks
ld
select part
from your_table
group by part
having
sum(OrderQty) - sum(ShippedQty) < max(QOH)

Optimizing deleting million rows in a SQL databse [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Imagine a situation when you have a table with 2 million rows and you wanted to delete a million rows. These rows are not bunched together. I might want to delete row1, and then row5, and then may be row7. But I want to deletes rows that may have age < 23 What is the best way to go about deleting these rows?
You will want to delete them in batches. This previous question provides some interesting answers.

Run Bash Script for 6 Hours using Sleep [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How do you use the sleep function to run the bash script every minute for say 6 hours?
Thanks
Wouldn't it be easier to setup a cron job?
min hour day month weekday command
*/1 10-15 * * * /path/to/your/script
10-16 is an example of a six hour block where it would run. 10 being 10AM and 15 being 3PM

insert only time in oracle [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
how to insert only time in hh:mi in oracle and how to run select query by comparing time.
Explanation:
Let consider a doctor visit in hospital daily from 9AM to 11AM and 6PM to 8PM.
SO when we run a select query to search doctors who visit at 10AM on particular day.
Please give explanation with code.
Thanks in advance.
You just need basic date arithmetic, and the plain old date type.
CREATE TABLE doctor_visits (
doctor_id NUMBER NOT NULL,
in_time DATE NOT NULL,
out_time DATE NOT NULL
)
/
I presume you want to find doctors who were in the hospital at 10:00am, as opposed to doctors who visited exactly at 10AM
SELECT doctor_id FROM doctor_visits
where in_time < trunc(in_time) + NUMTODSINTERVAL(10,'HOUR')
AND out_time > trunc(in_time) + NUMTODSINTERVAL(10,'HOUR') ;
I haven't considered the use case where in_time and out_time fall on different dates, i.e. say 11:00PM in and 2:00 am out.
OR IF you want to find a list of Doctors who visited the hospital exactly at 10:00AM then
SELECT doctor_id FROM doctor_visits where to_char(in_time,'HH:MI') = '10:00' ;
But that would be a very strange thing to query, as you really can't be sure if some one visits exactly at that specific time.

How to update the table with large size update query in oracle? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have large size of update query it is 320 Kb sql file. i can't execute that query/file.please help me i am using oracle 10g.only one column have that bulk data i used CLOB data type to the table.
I would try to execute it this way on Unix/Linux:
save the query to x.sql
sqlplus myuser/mypass#mydb
#x
If this does not work please include the relevant error codes and messages.

Resources