Querying multiple date ranges in one select
Hello guys,
DDL:
CREATE TABLE DBO.SALES (
TYPE VARCHAR(50)
, REVENUE DECIMAL(19,2)
, SALE_DATE_TIME DATETIME)
What I'm trying to figure out is how I can pass two dates to a where clause querying this table, a start date and an end date. From this I can group up the REVENUE for each TYPE (but there's more):
SELECT TYPE, COUNT(*) AS NBR_OF_SALES, SUM(REVENUE) AS TOTAL_REVENUE
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD
GROUP BY TYPE
I'd now like to add a couple of extra columns in the select that calculates the TOTAL_REVENUE equal to the time period of the two dates, but offset by 1 week, 1 month and 1 year, so that would be three columns. I'm guessing this would be possible with a
CROSS APPLY, but I just can't get my head around it at this time. Just for clarity, the expected output would contain these columns:
TYPE, NBR_OF_SALES, TOTAL_REVENUE, TOTAL_REVENUE_LAST_WEEK, TOTAL_REVENUE_LAST_MONTH, TOTAL_REVENUE_LAST_YEAR
Any help is greatly appreciated.
SELECT TYPE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN 1 ELSE 0 END) AS NBR_OF_SALES,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_MonthOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_MonthOffset
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND DATEADD(MONTH,1,@ENDPERIOD)
GROUP BY TYPE
Is this what you want?
We have three total columns per metric, one for the period, one for the period offset by a week, and one for the period offset by a month.
We've also adjusted the where so all the data for the offset period is included.
Similar Messages
-
Hi I am using below query
select count(*) from
select M.Login_name
, P.IND_PROD_LOGIN_ID
, count(P.IND_PROD_LOGIN_ID) over (partition by P.IND_PROD_LOGIN_ID) cnt
from CITI_USER_2.CCS_CUSTOMER_MAST M
, CITI_USER_2.CCS_CUSTOMER_PROD P
WHERE M.CUSTOMER_ID = P.CUSTOMER_ID and P.IND_PROD_LOGIN_ID not like '508127%'
and to_char( M.CREATE_DATE , 'DD/MM/YYYY') = '16/10/2009'
) where cnt = 1
and translate(Login_name,'x0123456789','x') is null
and i got the result as 10 records but if i try to put in the date range as below
select count(*) from
select M.Login_name
, P.IND_PROD_LOGIN_ID
, count(P.IND_PROD_LOGIN_ID) over (partition by P.IND_PROD_LOGIN_ID) cnt
from CITI_USER_2.CCS_CUSTOMER_MAST M
, CITI_USER_2.CCS_CUSTOMER_PROD P
WHERE M.CUSTOMER_ID = P.CUSTOMER_ID and P.IND_PROD_LOGIN_ID not like '508127%'
and to_char( M.CREATE_DATE , 'DD/MM/YYYY') between '16/10/2009' and '17/10/2009'
) where cnt = 1
and translate(Login_name,'x0123456789','x') is null
i got the result as 653 records
But it should be 10 only and when i check the records it is giving me wrong result.
Can someone highlight how to use the range between the date, i need to check the number of records between the date range from 01/05/2009 to 01/10/2009this is all happening because of
to_char( M.CREATE_DATE , 'DD/MM/YYYY') between '16/10/2009' and '17/10/2009'in your second query...
that is doing a string comparision not date comparision...
in string comparision
check this example...
select * from dual where '17/10/2009' > '16/10/2010'which will result a record but you might also observe that 17 th in 2009 is less than 16th of 2010. this is because here string comparision is ocurring.
you need to change it as....
M.CREATE_DATE between to_date('16/10/2009','DD/MM/YYYY') and to_date('17/10/2009','DD/MM/YYYY')so your query becomes...
select count(*) from
select M.Login_name
, P.IND_PROD_LOGIN_ID
, count(P.IND_PROD_LOGIN_ID) over (partition by P.IND_PROD_LOGIN_ID) cnt
from CITI_USER_2.CCS_CUSTOMER_MAST M
, CITI_USER_2.CCS_CUSTOMER_PROD P
WHERE M.CUSTOMER_ID = P.CUSTOMER_ID and P.IND_PROD_LOGIN_ID not like '508127%'
and M.CREATE_DATE between to_date('16/10/2009','DD/MM/YYYY') and to_date('17/10/2009','DD/MM/YYYY')
) where cnt = 1
and translate(Login_name,'x0123456789','x') is null check your answer and get back.
Ravi Kumar
Edited by: ravikumar.sv on Oct 16, 2009 3:12 PM -
Querying on date range issue?
Hi,
I'm looking for a solution for this issue,
In the DB Table there is a column of type TIMESTAMP. so when i query for date range using BETWEEN keyword it returns data inserted on next day at 12.00.00 AM
example :
Table A
ColumnA_
data1
data2
data3
ColumnTime_
08/03/2010 11.55.00 AM
08/04/2010 12.00.00 AM
08/04/2010 12.00.01 AM
here when I query using between (08/03/2010 and 08/04/2010) keyword on Column_Time then ,
Ouput
data1
data2
but I'm just looking for data1 in the output, any ideas?Between is inclusive of both boundaries:
column between condition1 and condition2Translates into
condition1 >= column
and
condition2 <= columnSo tell the code what you want ... in your case
condition1 >= column
and
condition2 < columnI'm not sure if you expect the >= or not...adjust as needed. -
Select multiple date ranges?
I am looking to select from a set of date ranges. I know that a UNION will work, but how to I get a valid set of results from multiple dates without a UNION?
example:
select date from test
where date >= '01-MAR-07 0000'
and date <= '02-MAR-07 0000'
and date >= '04-MAR-07 0000'
and date <= '08-MAR-07 0000'
order by date;
This gets zero records.
But if I use UNION:
select date from test
where date >= '01-MAR-07 0000'
and date <= '02-MAR-07 0000'
union
select datre from test
and date >= '04-MAR-07 0000'
and date <= '08-MAR-07 0000'
order by date;
It works, I get the records in no test table.
How can I structure this query to work without UNION?true, date is taken eh?
I am still running into an issue:
Let's say I am using the following context:
select date1, name from test
where name in ('SUNDAR', 'ASUNDAR')
and date1 >= '01-MAR-07 0000'
and date1 <= '03-MAR-07 0000'
or (date1 >= '05-MAR-07 0000'
and date1 <= 07-MAR-07 0000');
My results are wrong, it would not include the select as part of the or clause. -
Hi, I am using Oracle 10g. I want a query which gives me below output.
Data Setup
========
create table t_date_range (
ID number (2),
start_date date,
end_date date);
insert into t_date_range values (1,to_date('20110101', 'YYYYMMDD'),to_date('20110331', 'YYYYMMDD'));
insert into t_date_range values (2,to_date('20110401', 'YYYYMMDD'),to_date('20110531', 'YYYYMMDD'));
insert into t_date_range values (3,to_date('20110701', 'YYYYMMDD'),to_date('20110731', 'YYYYMMDD'));
insert into t_date_range values (4,to_date('20110901', 'YYYYMMDD'),to_date('20111130', 'YYYYMMDD'));
insert into t_date_range values (5,to_date('20111201', 'YYYYMMDD'),to_date('20111231', 'YYYYMMDD'));
commit;
SQL> select ID, to_char(start_date,'DD-MON-YYYY') START_DATE, to_char(end_date,'DD-MON-YYYY') END_DATE from t_date_range;
ID START_DATE END_DATE
1 01-JAN-2011 31-MAR-2011
2 01-APR-2011 31-MAY-2011
3 01-JUL-2011 31-JUL-2011
4 01-SEP-2011 25-OCT-2011
5 26-OCT-2011 30-NOV-2011
6 01-DEC-2011 31-DEC-2011
6 rows selected.
I want result in this form:
START_DATE END_DATE
01-JAN-2011 31-MAY-2011
01-JUL-2011 31-JUL-2011
01-SEP-2011 31-DEC-2011
Means if there is a difference of exact one day between "start_date of 2nd row" and "end_date of first row" then make a single row as shows in above results set.
Thanks!Hi,
Solomon Yakobson wrote:
Keep in mind, Franks's solution assumes date ranges do not overlap. ...That's true. If rows can overlap, then we might need to use two sub-queries, like you did: one to see if a new group starts with this row, and another to count how many new groups have already started.
The solution you posted assumes a relationship between id and dates. If we add a row like this to the sample data:
insert into t_date_range values (6,to_date('20101201', 'YYYYMMDD'),to_date('20121231', 'YYYYMMDD'));that overlaps all the others, then how would that solution work?
LAG won't work, because no matter how we sort the rows, we can't be sure that overlapping rows will be consecutive.
Here's one way to handle overlapping rows:
WITH got_new_grp AS
SELECT id, start_date, end_date
, CASE
WHEN start_date > 1 + MAX (end_date) OVER ( ORDER BY start_date
, id
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
THEN 1
END AS new_grp
FROM t_date_range
, got_grp AS
SELECT start_date, end_date
, COUNT (new_grp) OVER ( ORDER BY start_date
, id
) AS grp
FROM got_new_grp
SELECT MIN (start_date) AS start_date
, MAX (end_date) AS end_date
FROM got_grp
GROUP BY grp
ORDER BY start_date
;This solution uses id (assumed to be unique) just to get a consistent ordering, in case 2 (or more) rows have exactly the same start_date. It does not assume any relationship between ids and either start_date or end_date.
I'm also assuming that start_date<=end_date on each row.
Edited by: Frank Kulash on May 11, 2011 12:54 PM
The above refers to the solution you oriognally posted, which was:
with t1 as (
select id,
start_date,
end_date,
case
when lag(end_date) over(order by id) + 1 >= start_date then 0
else 1
end start_of_group
from t_date_range
t2 as (
select id,
start_date,
end_date,
sum(start_of_group) over(order by id) grp
from t1
select min(start_date) start_date,
max(end_date) end_date
from t2
group by grp
order by grp
; -
Multiple Data Sources In One Logical Table
I am new to OBIEE and I have came accross an issue. I appologize if this information is in the forum somewhere but I have searched and cannot find it.
My situation is that I would like to have one logical table that contains multiple data sources which have all the same columns. I already have session variables setup to differentiate the user's security through a row-wise variable for a specific column and a session variable for another column which determines the user's association to the data source in which they belong to. This security works well when the data sources are seperated in the Business Model and Mapping portion but the issue that arises is that the user's cannot share reports when the data sources are seperated in the BM&M.
I have dragged and dropped a table from the Physical model to the BM&M, I then dragged the second data source (with same meta data structure) over to the "Sources" folder in the first data source table in the BM&M. On the Content tab or each data source table I have defined the WHERE clause as such, where VALUEOF(NQ_SESSION."SCHOOL") session variable is my row-wise column filter and the VALUEOF(NQ_SESSION."GROUP") filter is my data source determinative:
sandbox."".SANDBOX.OBIEE_CROSS_ENROLLMENTS.HOME_SCHOOL = VALUEOF(NQ_SESSION."SCHOOL") AND sandbox."".SANDBOX.OBIEE_CROSS_ENROLLMENTS.DATA_SOURCE = VALUEOF(NQ_SESSION."GROUP")
Unfortunatley this only returns values in the BI Answers for the first drag and drop Pysical table in the BM&M layer and not the second Physical table drug into the "Sources" folder. I have also tried to create a new logical table and drag both tables into the "Sources" folder to no avail. I have experimented with the Fragmentation content on the "Content" tab of the seperate logical tables, checking the "This source should be combined with other sources at this level", which gives me an error in BI Answers that a column does not exist which really does.
What could I be missing? Advanced thanks to those who reply.
Thank you,
KyleStijn,
Thank you for the article link. That was very helpful! It seems that I had a few things off as you do need the "This source should be combined with other sources at this level." checked. In my two table source columns for DATA_SOURCE I defined a literal ('086496' and '085597' for the other) in the Column Mapping tab. I pasted the following in the Fragmentation content, checking the "This source..." box on the Content tab:
eSIS.SANDBOX4_SCHOOLS.DATA_SOURCE = '086496'
And pasted the following into the WHERE clause, checking "Select distinct values" on the Content tab:
sandbox4."".OBIEE.NWOCA_SCHOOLS.SCHOOL_CODE = VALUEOF(NQ_SESSION."SCHOOL") AND sandbox4."".OBIEE.NWOCA_SCHOOLS.DATA_SOURCE = VALUEOF(NQ_SESSION."GROUP")
This took care of my user's security, utilizing the session variables in the WHERE clause. I am now able to generate reports that only one user can access from one data source and share that same report with another user who can only see data from the other data source.
Many thanks!!! -
Space allocation on 11g R2 on multiple data files in one tablespace
hello
if the following is explained in Oracle 11g R2 documentation please send a pointer. I cant find it myself right now.
my question is about space allocation (during inserts and during table data load) in one table space containing multiple data files.
suppose i have Oracle 11g R2 database and I am using OMF and Oracle ASM on Oracle Linux 64-bit.
I have one ASM disk group called ASMDATA with 50 ASM disks in it.
I have one tablespace called APPL_DATA with 50 data files on it, each file = 20 GB (equal size), to contain one 1 TB table calll MY_FACT_TABLE.
During Import Data Pump or during application doing SQL Inserts how will Oracle allocate space for the table?
Will it fill up one data file completely and then start allocating from second file and so on, sequentially moving from file to file?
And when all files are full, which file will it try to autoextend (if they all allow autoextend) ?
Or will Oracle use some sort of proportional fill like MS SQL Server does i.e. allocate one extent from data file 1, next extent from data file 2,.... and then wrap around again? In other words it will keep all files equally allocated as much as possible so at any point in time they will have approximately the same amount of data in them (assuming same initial size ?
Or some other way?
thanks.On 10.2.0.4, regular data files, autoallocate, 8K blocks, I've noticed some unexpected things. I have an old, probably obsolete habit of making my datafiles 2G fixed, except for the last, which I make 200M autoextend max 2G. So what I see happening in normal operations is, the other files fill up in a round-robin fashion, then the last file starts to grow. So it is obvious to me at that time to extend the file to 2G, make it noautoexented, and add another file. My schemata tend to be in the 50G range, with 1 or 2 thousand tables. When I impdp, I notice it sorts them by size, importing the largest first. I never paid too much attention to the smaller tables, since LMT algorithms seem good enough to simply not worry about it.
I just looked (with dbconsole tablespace map) at a much smaller schema I imported not long ago, where the biggest table was 20M in 36 extents, second was 8M in 23 extents, and so on, total around 200M. I had made 2 data files, the first 2G and the second 200M autoextend. Looking at the impdp log, I see it isn't real strong about sorting by size, especially under 5M. So where did the 20M table it imported first end up? At the end of the auotextend file, with lots of free space below a few tables there. The 2G file seems to have a couple thousand blocks used, then 8K blocks free, 5K blocks used, 56K blocks free, 19K blocks used, 148K free (with a few tables scattered in the middle of there), 4K blocks used, the rest free. Looking at an 8G similar schema, looks like the largest files got spread across the middle of the files, then the second largest next to it, and so forth, which is more what I expected.
I'm still not going to worry about it. Data distribution within the tables is something that might be important, where blocks on the disk are, not so much. I think that's why the docs are kind of ambiguous about the algorithm, it can change, and isn't all that important, unless you run into bugs. -
Get Months for the given date ranges on the Selection Screen
Hello All,
If I give Begin Date (Begda) and End Date (Endda) on the Selection Screen, I need to get all the months given in the selection screen ranges.
Could any one please suggest me how to proceed further on this.
Thanks in Advance
Regards
YathishHI,
Check this FM
HR_99S_INTERVAL_BETWEEN_DATES ---> this can help you it will return the month in this table MONTH_TAB
HR_99S_MONTHS_BETWEEN_DATES -
Multiple Data Columns in one report column
How do I list multiple columns returned from a select vertically within one report column. For instance, I have three statuses for a project that I want to list, I'd like to list the three statuses within one status column. I remember seeing this somewhere but cannot find it now. Example:
Status Column
Budget: Green
Schedule: Red
Issues: Yellowadditionally you could use HTML expressions. When editing your report, click on the column you want to use for displaying multiple data columns. This will take you to the report columns attributes page, there you can type in something like the following into the HTML expression field, referencing other report columns using #COLUMN_NAME# substitutions:
#BUDGET#
#SCHEDULE#
#ISSUES#
this is assuming your column aliases are named BUDGET, SCHEDULE and ISSUES. You can then just hide the columns that you don't want to see because the data is already shown using the HTML expression.
Regards,
Marc -
Query for date range? DPL
Sorry if this has been answered before, but I couldn't find the answer. I'm new to the DPL and was trying to find out how to query for objects that fall within a "date range". If I have an object that has a field "effective date", I would like to query for a list of objects that fall between a date range. Can I do this with DPL?
thanks,
JohnHi,
Yes, the DPL can be used to iterate over the entities where a given date field D falls with a specified date range. To do this, you define D as a @SecondaryKey, create a SecondaryIndex for it, and get a cursor for the specified range using one of the SecondaryIndex.entities() methods. Be sure to close the cursor.
See the Key Ranges section in this class description:
http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/EntityCursor.html
Dates are treated as long values, so a range of Date keys is no different that a range of long keys. Date and long are both "simple types" according to the DPL definition.
--mark -
I have a query that will retrieve order between selected dates. It works great but returns no record if the 2 dates are the same.
Example:
Orders between 9-1-2010 and 9-30-2010 retunes 35 records.
But if I select between -9-25-2010 and 9-25-2010, so I can see all order from this 1 day, it returns 1 records, and I know there are records for that day!
Here's my query:
<%
Dim rsOrders__MMColParam
rsOrders__MMColParam = "1"
If (Request.QueryString("datefrom") <> "") Then
rsOrders__MMColParam = Request.QueryString("datefrom")
End If
%>
<%
Dim rsOrders__MMColParam2
rsOrders__MMColParam2 = "1"
If (Request.QueryString("dateto") <> "") Then
rsOrders__MMColParam2 = Request.QueryString("dateto")
End If
%>
<%
Dim rsOrders
Dim rsOrders_cmd
Dim rsOrders_numRows
Set rsOrders_cmd = Server.CreateObject ("ADODB.Command")
rsOrders_cmd.ActiveConnection = MM_ezcaldatasource_STRING
rsOrders_cmd.CommandText = "SELECT * FROM dbo.orders WHERE (OrderDate between ? and ?) AND Finalized = 1"
rsOrders_cmd.Prepared = true
rsOrders_cmd.Parameters.Append rsOrders_cmd.CreateParameter("param1", 135, 1, -1, rsOrders__MMColParam) ' adDBTimeStamp
rsOrders_cmd.Parameters.Append rsOrders_cmd.CreateParameter("param2", 135, 1, -1, rsOrders__MMColParam2) ' adDBTimeStamp
Set rsOrders = rsOrders_cmd.Execute
rsOrders_numRows = 0
%>2 possible
1) Change the column's data type from a datetime to a date if supported by your DBMS
2) Use date math to always add 1 day to the end date. So instead of the end date of 9-25-2010 (00:00) it will be 9-26-2010 (00:00) -
PROBLEM TRANSFERRING MULTIPLE DATA ENTRIES FOR ONE KEY-FIELD.
DEAR EXPERTS ,
I HAVE TRANSFERRED DATA FROM THE FINAL INTERNAL TABLE OF MY ABAP REPORT (NOT ALV) TO CUSTOM Z-TABLE CREATED IN SE11.
BUT MY PROBLEM IS : I COULD NOT TRANSFER MULTIPLE DATA ENTRIES FOR A PARTICULAR FIELD.
FOR EXAMPLE : IN TABLE EKKO THERE ARE FOUR EBELN-4900006375 AND FOR THAT DIFFERENT EBELP S ARE
PRESENT. I COULD TRANSFER ONLY THE FIRST ENTRY , THAT IS : EBELN - 4900006375 AND EBELP - 0010,
AFTER THAT THE ZTABLE IS NOT GETTING UPDATED TO EBELN-4900006375 FOR EBELP - 0020 AND SO ON.
I HAVE TRIED ALL THE ' MODIFY, INSERT, UPDATE ' STATEMENTS. I HAVE USED AT - USERCOMMAND - HIDE AND CHECKBOXES.
PLEASE SUGGEST A SAMPLE CODE FOR THIS.
Moderator message: please post again, but not in all upper case.
[Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
Edited by: Thomas Zloch on Jun 19, 2011 10:05 PMThere are actually 5 queries in this report now. From what I understand about a union query, I don't think it will work here because the data being returned in each of the queries is so different. I basically need to know how to make all the criteria for each individual to be displayed before proceeding to the next data set, which will include the same data as the first, but for the next employee, and so on. I need to basically create a repeating frame with each individual's respective data I guess, but every time I do, it tells me that it's referencing an invalid group.
-
CUIC Hourly Interval Query Throughout Date Range (SQL Squirrel Stuff)
I’m trying to create a specific report in CUIC using the "Contact Service Queue Activity Report by Interval” canned report. The objective is to query intervals (by hour), throughout the whole reporting time frame. This can be done by interval and reported per day in the canned report, but I’m trying to get the values per interval without the day displayed. For example, I’d like a report that shows total calls per hour (8-9 am, 9-10, 10-11am etc) throughout the reporting date range. The report would look like this:
Interval Start Time Interval End Time CSQ Name Calls Presented Handled
8:00:00 AM 9:00:00 AM CSQ_ 41 40
9:00:00 AM 10:00:00 AM CSQ_ 63 60
10:00:00 AM 11:00:00 AM CSQ_ 50 50
Instead of this:
Interval Start Time Interval End Time CSQ Name Calls Presented Handled
3/3/14 8:00 3/3/14 9:00 CSQ_ 16 16
3/3/14 9:00 3/3/14 10:00 CSQ_ 23 21
3/3/14 10:00 3/3/14 11:00 CSQ_ 24 24
3/4/14 8:00 3/4/14 9:00 CSQ_ 13 13
3/4/14 9:00 3/4/14 10:00 CSQ_ 26 25
3/4/14 10:00 3/4/14 11:00 CSQ_ 14 14
3/5/14 8:00 3/5/14 9:00 CSQ_ 12 11
3/5/14 9:00 3/5/14 10:00 CSQ_ 14 14
3/5/14 10:00 3/5/14 11:00 CSQ_ 12 12Hi
So you want the report to add up all the calls between 9-10am, e.g. if you run it for a week it would add up the calls for each day between 9 and 10 am and show a single total for that hour?
Aaron -
List item w/ multiple data items - how to select data items?
I have a list component (myListBox) that is showing the
labels for some data items read in from an XML file. Each item in
the list has an associated name, description, and path (they're mp3
files) and they are named accordingly in the XML tags.
Using myListBox.selectedItem.label gives the correct label
but myListBox.selectedItem.data is undefined. I've tried using the
XML tags after the data selector (e.g.
myListBox.selectedItem.data.path) but those don't work, either. All
of the examples I've found in the docs show only a single data
element associated with each list item.
So, if a list item has multiple data items associated with
it, how do you select them using the listBox.selectedItem property?
TIA,
rgamesQ2. when I type "Oracle" in A long list item box, cursor is going to the initial character "O" , so I can find "Oracle" in A long list item box easily.Maybe , but of course your list gets smaller as you see only the entries starting with a "O" , except if there are entries in the list which all start with the letter "O" so the total number of entries in the list is equivalent to the number of entries start with "O"...!!!!!!!!!
My greetings,
Simon -
Query for date range? JE
Hi,
I have seem some posts on the JE forum regarding quering for date range, but it is mostly using DPL.
Is there any way to do that using the JE API
Thanks,
MohammadHi Mohammad,
A date range query can be performed as a key range query. There's nothing special about dates except that you'll want to use a key binding that gives a meaningful sort order. If you're representing your dates in milliseconds, then a LongBinding (in com.sleepycat.bind.tuple) will work well. In general, use tuple bindings for keys, because they provide a meaningful sort order.
To perform a range query, this FAQ has some hints:
http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#28
On range searches in general, they can be done with Cursor.getSearchKeyRange or with the SortedSet.subSet and SortedMap.subMap methods, depending on whether you are using the base API or the Collections API. It is up to you which to use.
If you use Cursor.getSearchKeyRange you'll need to call getNext to iterate through the results. You'll have to watch for the end range yourself by checking the key returned by getNext. This API does not have a way to enforce range end values automatically.
If you use the Collections API you can call subMap or subSet and get an Iterator on the resulting collection. That iterator will enforce both the beginning and the end of the range automatically.
Does this answer your question?
--mark
Maybe you are looking for
-
Date Conversion Routine in Transfer Rules
Hi, Could you help me writing ABAP code for converting date field MM/DD/YYYY in to the same format. But my InfoObject is 8digit and displays into 10 digit DATS type Object. After loading data it is looking different formats at different loacations. E
-
How do I get my phone billed corrected without wasting another 3 hours?
On March 3, 2015, I ordered two “iPhone 6 plus 64 GB” along with 2 protective cases from verizonwireless.com/. The iPhones were on the edge plan, one was an upgrade and the other was a new line being transferred from Sprint. They were to be shipped
-
1st Gen Time Capsule won't setup
I bought a first Generation Time Capsule yesterday, I connected my ethernet cable from my verzion fios actiontec router and power the TC on. My 13 retina Macbook can see the TC, but whenever i try to connect to it in order to set it up i get this mes
-
IPod Touch and iTunes Will Not Work Together.
I just received a new iPod Touch 32GB yesterday and have had nothing but troubles trying to get it to play nicely with iTunes. The Touch is currently version 1.1.5/4B1 (I believe updated to this sometime yesterday). I am running iTunes v. 7.7.1 (11).
-
Copy and Paste Stops working across the Mac OS X
Recently I have been using my machine to connect to Windows XP machines using the RDC program (Mac equivilant of mstsc.exe) that Mircosoft provides. Whilst swtiching between applications on the host OS (Mac OS X 10.8) I found that my copy and paste f