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.
Related
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 much time will it take to delete and truncate 43GB of data in oracle
Since TRUNCATE is a DDL command, it will complete almost instantly-- almost certainly less than a few seconds unless you have an exceptionally large number of extents. Of course, that assumes that truncating the table is a valid option-- TRUNCATE cannot be rolled back, you cannot apply a WHERE clause to delete data selectively, the table cannot have any foreign key constraints, etc.
How long it will take to DELETE every row in the table depends heavily on your system. As Alex Poole pointed out in the comments, it will depend on system load, the number of indexes, the number of triggers, the number of constraints, etc.
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;
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 am planning to display an android calendar in my application. I want to select a date to use in my application. I need to know whether there is an algorithm for a calendar.
I must not use any open source application.
Generating an arbitrary Gregorian calendar pretty much amounts to determining the day of the week of the starting day and, for Februaries, determining whether the year is a leap year.
The best and most famous date algorithm is Conway's Doomsday Rule, http://en.wikipedia.org/wiki/Doomsday_rule
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.
Assume:
There are hundred students and each on
of them are working on a common
project.
Ideally, being consistent implies that a student works everyday on the project at-least once.
If we have data like this:
Student 1 work day 1(worked)
day 2(worked)
day 3(took a break)
etc
Now is there any algorithm that can be used to check and rank students based on consistency ?
EDIT:
This is not a homework problem. I am developing a plugin in java that rates group work according to consistency. So I was wondering if there was an algorithm that can accurately predict consistency. I was thinking about using standard deviation but if there is something more precise, it would help.
I believe the quantity you are looking for is called variance. This describes consistency, if you were to say, use the time each day that a student works.
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've been given a big query to figure out. But there are so many subqueries that it's nearly impossible.The number of subqueries is about 15-20.What do you suggest I do?
What I usually do when confronted with such monsters is:
Replace old style joins with new style ones
Modularize every non-trivial subquery into "virtual" tables using the with statement, for example:
with
subquery1 as (select /*big query*/ ),
subquery2 as (select /*big query*/ )
select *
from ...
join subquery1
where foo in (select foo from subquery2)
At that point some patterns emerge and more often than not the query can be rewritten in a sensible way.
The first thing I would do is to issue an explain plan to see how the DBMS would execute the query and go from there.