Query output based on the date range ...
Hi All,
I have an issue related to the jump query, main query based on the time frame. For Example if he selects Sold_To : 6895 for the Calday 10/01/2007 01/31/2008 and when jumps to jump query , the jump query should display the data based on the input given in the main query. That is it should show the data individually for four months.
Expecting the reply from your side...
Thanks in advance
Regards,
Sruthi
Sruthi,
Make sure that u have those 3 fields in 2nd Query and CALDAY with Variable.
Create settings in RSBBS.
Click on ASSIGNMENT DETAILS tab
CALDAY > Type = Variable > Selection Type = Selection/Single value/Multiple single values ( same like ur first query )
All other fields ( 3 na ) > Type = Generic
Click on Continue / Save.
If you need more info...if possible come to yahoo chat my ID is [email protected]....and am online now.
Regards,
Ramkumar.
Similar Messages
-
Creation of internal table dynamically based on the Date Range entered
Hi SAPgurus,
I have been facing one issue i.e creation of internal table dynamically based on the date range entered in the selection screen. For example the date range I am giving as 06/2006 to 08/2006, it should display the Fieldcatelog dynamically, this part i have completed but the only issue I am facing is to populate the sales data into that fields.
Right now my program is displaying the ALV like this.
Ex:
<b>CSR District 06/2006 07/2006 08/2006 totals</b>
Shiva New York 10.00
Shiva new york 30.00
Shiva new york 40.00
but it should display like this
<b>CSR District 06/2006 07/2006 08/2006 totals</b>
Shiva New York 10.00 30.00 40.00
80.00
Please help me in this scenario, how to acheive like this..
Thanks & Regards,
Sivaram KandulaHi Sivaram,
I also got the same requirement . i saw rich and your code whatever you have uploaded.i have created dynamic internal table but i am facing the issue to populating the data to my dynamic internal table.
Sivaram, can you please explain your code after this.
*<dyn_table>
*tab_item.
LOOP AT tab_item.
ASSIGN COMPONENT 1 OF STRUCTURE <dyn_wa> TO <dyn_table>.
ASSIGN COMPONENT 2 OF STRUCTURE <dyn_wa> TO <dyn_table>.
* <dyn_wa> = tab_item-bztxt.
* <dyn_wa> = tab_item-total.
* APPEND <dyn_wa> TO <dyn_table>.
** <dyn_wa> = tab_item-total.
** ASSIGN tab_item-bezei TO <dyn_wa>.
* APPEND <dyn_table>.
ENDLOOP.
how you are puting the loop at tab_item. but tab_item is already commented.
can you send me the code after that.
i am sending some part of my code.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fCAT1
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <dyn_table>.
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
select vbeln
fkart
vkorg
vtweg
fkdat
spart
fksto
from vbrk
client specified
into table gt_vbrk
where mandt = sy-mandt
and fkart in ('ZF5','ZFR')
and vkorg = '1100'
and vtweg = '20'
and fkdat in s_fkdat
and spart = '06'
and fksto = ' '.
if gt_vbrk[] is not initial.
select vbeln
fkimg
prsdt
netwr
matnr
arktx
werks
mwsbp
from vbrp
client specified
into table gt_vbrp
for all entries in gt_vbrk
where vbeln = gt_vbrk-vbeln
and werks in s_werks
and matnr in s_matnr.
endif.
select mnr ltx spras from t247
into table it_t247
where spras = 'E'.
data: lv_month1 type vbrp-prsdt,
name1(3) type c,
s_month type string,
s_month1 type string,
s_month2 type string.
* lv_netwr1 type vbrp-netwr,
* lv_mwsbp1 type vbrp-mwsbp.
loop at gt_vbrp into gs_vbrp.
gs_final2-matnr = gs_vbrp-matnr.
gs_final2-arktx = gs_vbrp-arktx.
gs_final2-fkimg = gs_vbrp-fkimg.
lv_month1 = gs_vbrp-prsdt.
read table it_t247 into wa_t247 with key mnr = lv_month1+4(2).
if sy-subrc eq 0.
name1 = wa_t247-ltx.
endif.
concatenate name1
lv_month1(4) into s_month SEPARATED BY '_' .
CONCATENATE S_MONTH 'QTY' INTO S_MONTH1 SEPARATED BY ''.
CONCATENATE S_MONTH 'VALUE' INTO S_MONTH2 SEPARATED BY ''.
gs_final2-month = s_month.
lv_netwr1 = gs_vbrp-netwr.
lv_mwsbp1 = gs_vbrp-mwsbp.
gs_final2-MONTH_QTY = S_MONTH1.
GS_FINAL2-MONTH_VAL = S_MONTH2.
gs_final2-value = lv_netwr1 + lv_mwsbp1.
append gs_final2 to gt_final2.
clear: gs_final2. "lv_name2.
endloop.
if gt_final2[] is not initial.
sort gt_final2 by matnr month ascending .
loop at gt_final2 into gs_final2.
gs_final2_01 = gs_final2.
collect gs_final2_01 into gt_final2_01.
endloop.
endif.
ENDIF..
Regards
Ankur -
I want to query based on a date range. I wrote the following EJB QL:
"select object(a) from ActionItems as a where a.dueDate
between ?1 and ?2"
But when I deployed the application to Oracle's EJB server, I got the following error:
Auto-deploying biogen.jar (No previous deployment found)... Invalid type for expression (a.dueDate BETWEEN ?1 AND ?2)
EJB QL statement : 'select object(a) from ActionItems as a where a.dueDate between ?1 and ?2'
EJB QL method : public abstract java.util.Collection ActionItemsLocalHome.findByDueDateRange(java.sql.Date,java.sql.Date) throws javax.ejb.FinderException
at com.sun.ejb.ejbql.parser.EjbQLParser.parse EjbQLParser.java:218)
at com.sun.ejb.ejbql.EjbQLDriver.parse(EjbQLDriver.java:86)
at com.sun.ejb.sqlgen.SQLGenerator.generateSQLForEjbQLQueries(SQLGenerator.java:704)
It works fine for a number range, but does not work for a date range.
Any one has an idea on how to write a correct EJB QL for a query based on date range?
Thanks.
JingzhiRe-posted. Please help!
-
MDM ABAP API query to pass the date range
Hi
I want to retrieve certain data from MDM repository based on filter criteria by date stamp.
Not sure how to do it to pass the select option value in the query.
select-options: s_cdate for sy-datum obligatory .
DATA wa_query TYPE mdm_query.
DATA: v_search_date1 TYPE MDM_CDT_DATE_TIME.
data: v_datestamplow1 type string.
data: v_datestamplow type TZNTSTMPL.
concatenate s_cdate-low '000000' into v_datestamplow1
v_datestamplow = v_datestamplow1.
clear wa_query.
wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
wa_query-operator = 'EQ'.
wa_query-dimension_type = mdmif_search_dim_field. "Field search
wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
I am able to get the data when I just pass the low value from selecct option. But I dont how to pass the date range.
v_search_date1-CONTENT = v_datestamplow.
ET REFERENCE OF v_search_date1 INTO wa_query-value_low.
APPEND wa_query TO gt_query.
CALL METHOD cl_api->mo_core_service->query
EXPORTING
iv_object_type_code = 'Vendors'
it_query = gt_query
IMPORTING
et_result_set = gt_result.
II could see the below operator types . Although EQ says "Like standard select-options parameter" not sure how to pass the value.
EQ Equal to (like standard select-options parameter)
NE Not equal to (like standard select-options parameter)
LT Less than (like standard select-options parameter)
LE Less than or equal to (like standard s-o parameter)
GT Greater than (like standard select-options parameter)
GE Greater than or equal to (like standard s-o parameter
SW Starts with (MDM specific parameter)
Thanks,
Krishna.Hi,
To get the date range for select options, pass the low value with 'GE' operator and another query option with 'LE' operator for high value.
select-options: s_cdate for sy-datum obligatory .
DATA wa_query TYPE mdm_query.
DATA: v_search_date1 TYPE MDM_CDT_DATE_TIME.
data: v_datestamplow1 type string.
data: v_datestamplow type TZNTSTMPL.
concatenate s_cdate-low '000000' into v_datestamplow1
v_datestamplow = v_datestamplow1.
clear wa_query.
wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
wa_query-operator = 'GE'.
wa_query-dimension_type = mdmif_search_dim_field. "Field search
wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
GET REFERENCE OF v_search_date1 INTO wa_query-value_low.
APPEND wa_query TO gt_query.
concatenate s_cdate-high '235959' into v_datestamphigh1
v_search_date2 = v_datestamphigh1.
clear wa_query.
wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
wa_query-operator = 'LE'.
wa_query-dimension_type = mdmif_search_dim_field. "Field search
wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
GET REFERENCE OF v_search_date2 INTO wa_query-value_low.
APPEND wa_query TO gt_query.
CALL METHOD cl_api->mo_core_service->query
EXPORTING
iv_object_type_code = 'Vendors'
it_query = gt_query
IMPORTING
et_result_set = gt_result.
Thanks. -
Can I use SYSDATE in the WHERE clause to limit the date range of a query
Hi,
Basicaly the subject title(Can I use SYSDATE in the WHERE clause to limit the date range of a query) is my question.
Is this possible and if it is how can I use it. Do I need to join the table to DUAL?
Thanks in advance.
SteliosAs previous poster said, no data is null value, no value. If you want something, you have nvl function to replace null value by an other more significative value in your query.<br>
<br>
Nicolas. -
Metrics generation based on (birth) date ranges
Hello all,
Am a beginner in OBIEE. Am trying to derive some metrics out of birthdate information I have. Its a 2 part question.
1) Count of occurrence of birthdates.
Its a simple count(*) query and this I was able to get it done in OBIEE - all the formatting is done
Eg:
source data
*19300203*
*19300203*
*18301203*
*19600204*
metrics out of that
*19300203 - 2*
*18301203 - 1*
*19600204 - 1*
2) Count of birthdate based on period distribution.
Now, categorizing the date range in to 3 distributions.
a) before 1900
b) 1900 to 1950
c) after 1950
output will should be something like -
before 1900 - 1
*1900 to 1950 - 2*
after 1950 - 1
I tried a lot and searched in forums and now stuck really and could not proceed with this type of data generation model.
Can you please show some pointers on how I can proceed with this?
Many thanks.Hi,
Bit tricky without more details of your model, but im guessing you have a date dimension and a fact with your count measure.
I'd start in answers, create some 'Bins' on your date column or manually write a case statement to create the attribute you want to group the counts by (ie :
when date < 1900 then 'Before 1900' else when < 1951 then '1900 to 1950' else 'after 1950)
If your happy with this result, I'd move the case statement back into the RPD BMM layer as a logical column in your Date dimension and go from there. This way the grouping of dates is available across other reports and is not confined to a specific formula in the report you are currently working on.
HTH, let us know if you get stuck. -
Hi,
There is a requirement that we need to get date range.This date range will be arrived at using the function module BKK_GET_PRIOR_WORKDAY. The factory calender id is GB. It should return the date range. Therefore, for weekends the date range will be Saturday, Sunday and Monday. The date range will change based on holidays that exist in the holiday calendar.
Now my question is how to calculate that there are two days between friday and monday.
Please help.Hi Nishigandha,
If i am correct you need the number of days between two dates
ex:
date1: 04/06/2009
date2: 12/06/2009
you need the number of days??
then probably check this Fm out:
SD_DATETIME_DIFFERENCE this is a function module which gives the difference in Days and Time for entered two dates
P.S Additionally Chk this out:
/people/mustafabaris.gunes/blog/2009/03/16/calculating-number-of-working-days-in-query-level
Hope its useful
Thanks and Regards
Srikanth.P
Edited by: SRIKANTH P on Jun 4, 2009 2:33 PM -
Percentage based on the Date and Dimension - WEBI
Hello,
I have to calculate percentage based on the Dates and a Dimension.
I have BEX Query as source and reporting is done on BOXI - WEBI
Here is the table structure in the report.
List# , Process01, Process02.
List# is unique and Process01-Has 4 operations, Process02 has 3 operations (and these Operations can change from 3 to 7 or 2).
Operations will have a 'Date' only when it is completed.
and when all the operations in a 'Process' have 'Date' then i need to get the 'Latest Date'. If few of the operations are not confirmed, then i need to get the percentage like when 2 of 4 operations have date it will be 50% and when no operation is confirmed then 0% and so on .
Example Cube data:
List#,ProcessCategory,Operation,Date
100,Process01,456,11/11/2010.
100,Process01,457,11/12/2010.
100,Process01,489,
100,Process01,490,
100,Process02,890,11/13/2010.
100,Process02,891,11/14/2010.
100,Proceess02,892,11/15/2010
Result:
List#, Process01, Process02
100,50%,11/15/2010.
Please help me in this, i tryed different logics but it is giving ERROR at percentage.
Your help would be appreciated!
Thanks in advance.I applied this:
If([Process Category] InList("Process01") And IsNull([Date]);[Percentage];Max(Date)))
[Percentage] = (Count([Date])/Count([Operation]))*100.
but, this is not becoming true - even when Operation has one Date
Showing result as:
List#,Process01,Process02
100, 11/12/2010, 11/15/2010
But result should be
100,50%,11/15/2010
Can anyone help me achieve the right result!
Thanks in advance. -
Is it possible to find the table based on the Date ?
Dear Team ,
Is it possible to find the table based on the Date ?
I have created an table ,But forgot the Table Name .
Is it possible to find the Tables created on particular Date .
Regards ,
Augustineas date is record the time also below query will work.
select * from user_objects
where
object_type = 'TABLE' and
to_date(created,'DD-MON-YYYY') =to_date('<your date value in DD-MON-YYYY format>','DD-MON-YYYY');
Edited by: shaileshM on Feb 24, 2010 9:39 PM -
Header row in ALV Grid, based on the data in the table
Hi All,
I have a requirement wherein, based on the data in the table used for ALV, i need to add rows as sort of header in the ALV display.
For e.g. my table has
Appl No. Item Material Desc. Cost -> Column Heading
1 10 400 Excavation 10.00 -> Data
1 20 400 Footing 10.00
2 10 400 Excavation 10.00
2 20 400 Footing 10.00
For every new Appl No., i need to add a row, or sort of header specifying the appl no. details. means
Appl No. Item Material Desc. Cost
Appli. No. 1 Date: 01/01/1009 -> my requirement
1 10 400 Excavation 10.00
1 20 400 Footing 10.00
Appli. No. 2 Date: 02/01/1009
2 10 400 Excavation 10.00
2 20 400 Footing 10.00
Is this possible in ALV my any means? Currently i m using normal ALV Grid
Regards,
JanakiHi..
Try like this... I think u have Application number and date in ur table ... First get the total table data into internal table.. and to add the row
*Declare the var1 as 0 and var2.
loop at internal table
*var1 = var1 +1
when application number =var1
concatenate : 'Appli. No.' (table- appli no field) 'Date:' (table-date field) into var2.
perform display(some name)
*endloop.
*form display...
alv display part.. first give that var2 like eg.. wa_alv-field= 'var2'.
end form.
Hope this will help u .....
Regards,
Abaper -
Setting the series color of a bi beans graph based on the data values
How do I conditionally set the series color of a bi beans graph based on the data values?
I am using the following code to get the data values and set the series color:
Graph gr=(Graph)CmdrDashboardP1_pres1.getView();
DataAccess da=gr.getGraphModel().getDataAccess();
DataDirector dd=gr.getDataDirector();
DataMap dm=dd.getDataMap();
int re=dd.ROW_EDGE;
int ce=dd.COLUMN_EDGE;
Object val=da.getValue(re,ce,dm.DATA_TYPE);
int seriesCount=da.getEdgeCurrentSlice(DataDirector.ROW_EDGE);
if (val <=45.0)
gr.getSeries().setColor(new Color(255,0,0),seriesCount);
I get a NullPointerException from the line of code "Object val=da.getValue(re,ce,dm.DATA_TYPE)." I have tried the code with DATA_UNFORMATTED as well, but get the same exception. When I print the DataMap value of dm the results are [dataUnformatted, dataViewFormat, value, dataIsTotal, dataType].
Also, I get the error "method <= (java.lang.Object,double) not found in class _CmdrDashboardP1" from the "if (val <=45.0)" code.
Thanks for any assistanceHow do I conditionally set the series color of a bi beans graph based on the data values?
I am using the following code to get the data values and set the series color:
Graph gr=(Graph)CmdrDashboardP1_pres1.getView();
DataAccess da=gr.getGraphModel().getDataAccess();
DataDirector dd=gr.getDataDirector();
DataMap dm=dd.getDataMap();
int re=dd.ROW_EDGE;
int ce=dd.COLUMN_EDGE;
Object val=da.getValue(re,ce,dm.DATA_TYPE);
int seriesCount=da.getEdgeCurrentSlice(DataDirector.ROW_EDGE);
if (val <=45.0)
gr.getSeries().setColor(new Color(255,0,0),seriesCount);
I get a NullPointerException from the line of code "Object val=da.getValue(re,ce,dm.DATA_TYPE)." I have tried the code with DATA_UNFORMATTED as well, but get the same exception. When I print the DataMap value of dm the results are [dataUnformatted, dataViewFormat, value, dataIsTotal, dataType].
Also, I get the error "method <= (java.lang.Object,double) not found in class _CmdrDashboardP1" from the "if (val <=45.0)" code.
Thanks for any assistance -
How to enable/disable the input fields based on the data entered in the web dynpro application abap? If the user enters data in one input field then only the next input field should be enabled else it should be in disabled state. Please guide.
Hi,
Try this code.
First create a attribute with the name readonly of type wdy_boolean and bind it read_only property of input field of which is you want to enable or disable.
Next go to Init method.
Set the readonly value as 'X'.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_visible TYPE wd_this->element_context-visible.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* @TODO fill attribute
* lv_visible = 1.
* set single attribute
lo_el_context->set_attribute(
name = `READONLY`
value = 'X').
After that Go to the Action ENTER.
First read the input field ( first input field, which is value entered field) , next give a condition
if input value is not initial then set the readonly value is ' '.
DATA lo_nd_input TYPE REF TO if_wd_context_node.
DATA lo_el_input TYPE REF TO if_wd_context_element.
DATA ls_input TYPE wd_this->element_input.
DATA lv_vbeln TYPE wd_this->element_input-vbeln.
* navigate from <CONTEXT> to <INPUT> via lead selection
lo_nd_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
* @TODO handle non existant child
* IF lo_nd_input IS INITIAL.
* ENDIF.
* get element via lead selection
lo_el_input = lo_nd_input->get_element( ).
* @TODO handle not set lead selection
IF lo_el_input IS INITIAL.
ENDIF.
* get single attribute
lo_el_input->get_attribute(
EXPORTING
name = `VBELN`
IMPORTING
value = lv_vbeln ).
if lv_vbeln IS not INITIAL.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_visible TYPE wd_this->element_context-visible.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* @TODO fill attribute
* lv_visible = 1.
* set single attribute
lo_el_context->set_attribute(
name = `READONLY`
value = ' ' ). -
Get Old Value and the new value based on the date
Hi
I have a table called roster created below with following insert statements.
CREATE TABLE ROSTER
ROSTER_EMPLOYEE_DEF_ID NUMBER,
EMPLOYEE_ID NUMBER,
DEFINITION_REGION_CODE NUMBER,
DEFINITION_DISTRICT_CODE NUMBER,
DEFINITION_TERRITORY_CODE NUMBER,
START_DATE DATE,
END_DATE DATE
INSERT INTO ROSTER
(ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
VALUES
(1,299,222,333,444,'1-JUN-2011','30-JUN-2011')
INSERT INTO ROSTER
(ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
VALUES
(2,299,223,334,445,'1-JUL-2011','20-JUL-2011')
INSERT INTO ROSTER
(ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
VALUES
(3,299,224,335,446,'1-AUG-2011','30-AUG-2011')
INSERT INTO ROSTER
(ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
VALUES
(4,300,500,400,300,'1-JUN-2011','20-JUN-2011')
INSERT INTO ROSTER
(ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
VALUES
(5,300,501,401,301,'1-JUL-2011','20-JUL-2011')
In the above table we have columns like
EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE
The result i am looking from the above table is based on the EMPLOYEE_ID OF START_DATE AND END_DATE
I need to get OLD_DEFINITION_REGION_CODE and the NEW_DEFINITION_CODE
Similarly OLD_DEFINITION_REGION_CODE and the NEW_DEFINITION_REGION_CODE
and OLD_DEFINITION_TERRITORY_CODE and the NEW_DEFINITION_TERRITORY_CODE
I need to get one row of data for each employee saying old value and new value
for employee 299 there are 3 records it must give the new record which is the latest date i.e start date 1-aug-2011 and end date 30-aug-2011 old record will be
start date 1-jul-2011 and 20-jul-2011
For the above table data i need to get the data as below
EMPLOYEE_ID OLD_DEFINITION_REGION_CODE NEW_DEFINITION_CODE OLD_DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE START_DATE END_DATE
299 223 224 334 335 20-JUL-11 30-AUG-11
300 500 501 400 401 20-JUN-11 20-JUL-11
Please suggest me to get the above result based on the data. Please let me know if my posts are not clear
Thanks
SudhirSELECT EMPLOYEE_ID,
OLD_DEFINITION_REGION_CODE,
NEW_DEFINITION_REGION_CODE,
OLD_DEFINITION_DISTRICT_CODE,
NEW_DEFINITION_DISTRICT_CODE,
OLD_DEFINITION_TERRITORY_CODE,
NEW_DEFINITION_TERRITORY_CODE,
START_DATE,
END_DATE
FROM (
SELECT EMPLOYEE_ID,
ROW_NUMBER() OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE DESC) RN,
LAG(DEFINITION_REGION_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_REGION_CODE,
DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE,
LAG(DEFINITION_DISTRICT_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_DISTRICT_CODE,
DEFINITION_DISTRICT_CODE NEW_DEFINITION_DISTRICT_CODE,
LAG(DEFINITION_TERRITORY_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_TERRITORY_CODE,
DEFINITION_TERRITORY_CODE NEW_DEFINITION_TERRITORY_CODE,
LAG(END_DATE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) START_DATE,
END_DATE
FROM ROSTER
WHERE RN = 1
EMPLOYEE_ID OLD_DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE OLD_DEFINITION_DISTRICT_CODE NEW_DEFINITION_DISTRICT_CODE OLD_DEFINITION_TERRITORY_CODE NEW_DEFINITION_TERRITORY_CODE START_DAT END_DATE
299 223 224 334 335 445 446 20-JUL-11 30-AUG-11
300 500 501 400 401 300 301 20-JUN-11 20-JUL-11
SQL> SY. -
Hi,
I have a table that records the leave for employees. Like employee id , leave start date, leave end date and total hours. I need to find out , if the start date or end date was on weekend , or if the date range includes weekends . And there is one more table that stores public holidays. I also need to check if the leave start date or end date was on the public holiday or the range includes any public holidays.
ThanksHi,
Assuming the time of day for all the dates involved is the same (e.g., if they are all TRUNCated DATEs, where the time is 00:00:00), that leave_start_date <= leave_end_date, and that the weekend consiists of Saturday and Sunday, you can do something like this:
SELECT leave_start_date
, leave_end_date
, CASE
WHEN TRUNC (leave_start_date, 'IW') < TRUNC (leave_end_date + 2, 'IW')
THEN 'Includes Saturday or Sunday'
ELSE 'No weekend'
END AS weekend
, CASE
WHEN EXISTS (
SELECT 1
FROM holiday_table
WHERE holiday_date BETWEEN m.leave_start_date
AND m.leave_end_date
THEN 'Leave includes at least 1 holiday'
ELSE 'No holidays'
END AS holiday
FROM leave_table m
;This does not depend on your NLS settings.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for both tables, and also post the results you want from that data, as Andy requested.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using. -
How to use SQL to display Datethat falls between the date range
Hi,
I'm figuring out how do i use SQL to select data
that falls between the date range stated
(for eg. 19/02/1955 to 19/02/2003)
I've tried :
sql="Select * From StudentRecords WHERE DOB BETWEEN #" jTextField21.getText() "#" +" And " +"#" +jTextField22.getText;
Using BETWEEN statment , but Between Statement isn't doing what i want..
even those out of range are displayed... any ideas how??
Thank yOU in advance!oracle:
sql = "Select * From StudentRecords WHERE DOB between TO_DATE('07/04/2003','dd/mm/yyyy') and TO_DATE('08/04/2003','dd/mm/yyyy')";
Maybe you are looking for
-
How do I install FlipShare on my MacBook?
I plugged my flip camera in and a program setup thing appeared in the corner, when I clicked on it a lot of different things came up. I tried all of them but they were confusing and I wasn't sure what to do. I tried to click "start FlipShare" but it
-
Firewire input for OnLocation CS4
Hi all, i have been using a firewire out of my Panasonic 3CCD HD camera to a firewire in on an older vista machine. i have upgraded to an Envy 15-1050NR computer. It has 3 Universal Serial Bus(USB) 2.0,3rd port shared with eSATA Headphone-out/Micro
-
Want to delete the IR user created condition before running new condition
Hi, The user wants to use the IR Search to do the following: 1.) Enter 'BILL', hit the "Go" button and it shows rows that have BILL inn one or more of the columns and it creates a "Row text contains 'BILL'" delete anchor. 1.) Enter 'JOHN', hit the "G
-
Pre 2.01 I was able to upgrade apps via the app store with the iphone 3g. Now updates will not load directly on the iphone. Yet, when trying to update via iTunes the updated apps will not overwrite or update the apps on the phone and I get an error m
-
Can't use Apple id to sign in to itunes
Here are the specifics: When I try to sign in, I get a message that "This apple id has not yet been used at the itunes music store" and I am taken to the contract page. I agree to the contract. Next, I am taken to the credit card info page. The scree