Correct way to do "where " clause on date type column
Hi,
I am using a following query in Oracle 10.2.0.3 express edition database to retrieve the rows greater than a certain date.
select from FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$ where TIME_STAMP > to_date('31-OCT-12');*
This query returns all the rows including the rows with TIME_STAMP == '31-OCT-12'.
This TIME_STAMP column is defined as below in this table:
COLUMN_NAME DATA_TYPE DATA_LENGTH NULLABLE CONSTRAINT_TYPE INDEX_TYPE
TIME_STAMP DATE 7 N C NORMAL
Table has 420 rows with '31-OCT-12' being the smallest date and '16-NOV-12' being the biggest.
Is there anything wrong in my above query?
Why is ">" returning the rows that include primary key where-clause value also?
Can you please guide what is the correct syntax for this date comparison?
Thanks for your time and help.
Best Regards.
907882 wrote:
Hi,
I am using a following query in Oracle 10.2.0.3 express edition database to retrieve the rows greater than a certain date.
select from FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$ where TIME_STAMP > to_date('31-OCT-12');*
This query returns all the rows including the rows with TIME_STAMP == '31-OCT-12'.
This TIME_STAMP column is defined as below in this table:
COLUMN_NAME DATA_TYPE DATA_LENGTH NULLABLE CONSTRAINT_TYPE INDEX_TYPE
TIME_STAMP DATE 7 N C NORMAL
Table has 420 rows with '31-OCT-12' being the smallest date and '16-NOV-12' being the biggest.
Is there anything wrong in my above query?
Why is ">" returning the rows that include primary key where-clause value also?
Can you please guide what is the correct syntax for this date comparison?
Thanks for your time and help.
Best Regards.Remember that a date column also contains a time part. Therefore your query would pick up
rows with a time_stamp of 31-Oct-12 13:40:09, for example. Now that is greater than 31-Oct-12
(which is really 31-Oct-12 00:00:00), so it is picked up.
You probably want >= to_date('1-Nov-2012', 'dd-mon-yyyy')
Note: always use a format mask in a to_date, otherwise if the default format mask changes, your code will break.
BTW: please mark your threads as answered, if they have been:
>
Handle: 907882
Status Level: Newbie
Registered: Jan 13, 2012
Total Posts: 9
Total Questions: 6 (5 unresolved)
>
Edited by: Paul Horth on Nov 27, 2012 9:30 AM
Similar Messages
-
Moving a table with long data type column
hi
1.how to move a table with a long data type column in 8.1.7.3.0 ver database.
alter table APPLSYS.FND_LOBS_DOCUMENT move lob(BLOB_CONTENT) store as (tablespace testing)
ERROR at line 1:
ORA-00997: illegal use of LONG datatype
2. and a table with varray type column
alter table APPLSYS.WF_ERROR move lob("USER_DATA"."PARAMETER_LIST") store as (tablespace testing)
ERROR at line 1:
ORA-22917: use VARRAY to define the storage clause for this column or attribute
table description is:
SQL> desc applsys.wf_error;
Name Null? Type
Q_NAME VARCHAR2(30)
MSGID NOT NULL RAW(16)
CORRID VARCHAR2(128)
PRIORITY NUMBER
STATE NUMBER
DELAY DATE
EXPIRATION NUMBER
TIME_MANAGER_INFO DATE
LOCAL_ORDER_NO NUMBER
CHAIN_NO NUMBER
CSCN NUMBER
DSCN NUMBER
ENQ_TIME DATE
ENQ_UID NUMBER
ENQ_TID VARCHAR2(30)
DEQ_TIME DATE
DEQ_UID NUMBER
DEQ_TID VARCHAR2(30)
RETRY_COUNT NUMBER
EXCEPTION_QSCHEMA VARCHAR2(30)
EXCEPTION_QUEUE VARCHAR2(30)
STEP_NO NUMBER
RECIPIENT_KEY NUMBER
DEQUEUE_MSGID RAW(16)
SENDER_NAME VARCHAR2(30)
SENDER_ADDRESS VARCHAR2(1024)
SENDER_PROTOCOL NUMBER
USER_DATA APPS.WF_EVENT_T
lob column:
SQL> select owner,table_name,column_name from dba_lobs where table_name='WF_ERROR';
OWNER TABLE_NAME COLUMN_NAME
APPLSYS WF_ERROR "USER_DATA"."PARAMETER_LIST"
APPLSYS WF_ERROR "USER_DATA"."EVENT_DATA"
pls help me
thanks and regards
srinivas1. Export and import
2. Sql*Plus 'copy' command
It is a good idea to move from 'LONG' to 'CLOB'. -
Getting past days data based on DATE data type column
I am trying to extract last 2 days data using date data type column with below query,
select * from tbl
where col < col -2;
this is not showing me any data. please help where i am making mistake. guide please. thxHi,
When you say "last 2 days" do you mean the 48 hours right before run-time?
If so, you want to compare col to SYSDATE:
select *
from tbl
where col > SYSDATE - 2
and col <= SYSDATE
;If you mean the "last 2 days" before some other event, then replace SYSDATE with that date in both places above.
If you were trying
where col > col - 2then you should have been getting all rows that have a non-NULL col. If you were getting no results, then something is very wrong.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
If the results depend on when you run the query, then give a couple of different examples, with the run-time. for example "If I run this at 03:00:00 on July 1, 2012, then I should get ... but if I run ir at 15:00:00 on July 1, 2012, then the results should be ...".
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using.
See the forum FAQ {message:id=9360002} -
How to insert in long data type column
I would like to know how could I insert data in a long data type column.
ThanksDon't use LONG, use CLOB instead. You can write to CLOBs using the DBMS_LOB package.
Cheers, APC -
I am creating a coditional query for one of my data blocks.
What I need to do is build a where clause on the fly and pass
that back to my block using the Set_BLock_Property built in. I
am able to do this but I am having problems with the fact that I
don't know how to correctly pass a date back. It seems when
specifying a date in a where clause it needs to have single
quotes around this. But when ever I try to embed the quotes in
the string I am not successful. I have even tried appending the
quotes using the chr function doing something like.
Where_Clause := 'Birthday <= 'Spencer,
I think chr(39) will give you the correct character. For example,
Where_Clause := 'Birthday <= ' -
I'm running Forms 6i client/server.
I have defined a where clause in the Property Palette for a Data Block.
What I like to do is to extend the where clause with a subquery, but
how can this be done? I mean, should I put the code in a trigger, which trigger?
Regards
Roarsimple where clause with sub_query
My block has name is dc_gmod. In the where pallete I put the text (and the all is work good!!!):
exists
select 1 from ttt.xxxxx_table v
where (dc_gmod.cd_gmod = v.cd_gmod)
and
(instr(:fst.tmp_nm,cd_place,1) > 0
or
cd_place IN
(select U_UNIT from ttt.xxxxxxxxx_tabe
where RG_U = :QA.RG_UNIT_RUN
AND SID = :QA.SID
AND SERIAL# = :QA.SERIAL
1.The dc_gmod.cd_gmod - is full name my block_name and item_name.
2. The ttt.xxxxx_table is full name of my table what is source for block dc_gmod
3. The cd_place is ITEM of BLOCK dc_gmod -
Hi specialist's,
i have a simple question about a select, but I think I do not see the forrest becaus of too many trees ...
I have a table where timestamps are stored in seconds-since-epoch.
I select a human readble format with this statement:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog;
TIMESTAMP
19-10-2013 09:31:27
19-10-2013 09:31:27
19-10-2013 09:31:27
Now I want to filter i.e. for dates of 19-01....
My first try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where timestamp like '19-%'
Result:
ORA-00904: "TIMESTAMP": invalid identifier
My next try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where 1 like '19%'
Result: 0 rows!
If I change this to
... where 1 like '%'
I get all rows.
What is wrong with my selects ???Felix_GG wrote:
Hi specialist's,
i have a simple question about a select, but I think I do not see the forrest becaus of too many trees ...
I have a table where timestamps are stored in seconds-since-epoch.
I select a human readble format with this statement:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog;
TIMESTAMP
19-10-2013 09:31:27
19-10-2013 09:31:27
19-10-2013 09:31:27
Now I want to filter i.e. for dates of 19-01....
My first try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where timestamp like '19-%'
Result:
ORA-00904: "TIMESTAMP": invalid identifier
My next try was this:
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where 1 like '19%'
Result: 0 rows!
If I change this to
... where 1 like '%'
I get all rows.
What is wrong with my selects ???
Firstly, why not store timestamps as timestamps?
Anyway, Your first select refers to the alias 'timestamp' which is only accessible in an outer query, not from within the where clause.
Try
Select * from (
select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS') as timestamp from txlog
where timestamp like '19-%';
But timestamp is not a good choice for an alias, as it is a keyword.
Your second select is obvious - the number 1 will never be like '19%', but it will work
in the third select: as 1 is indeed like '%' (anything). -
ADF Struts UIX - how write where clause whith date in ViewObject
Hello
I need to write a search form with two date fields and then query a where clause between to_date('date 1') and to_date('date 2').
the query may be writed in ViewCriteria class or using Application module method like this
AssureViewImpl assureView=getAssureView1();
assureView.applyViewCriteria(null);
assureView.setWhereClause("NUM_ASSU = :1");
assureView.setWhereClauseParam(0,numAss);
thanks a lot for your helpDoes the user always specify both start and end dates?
-
I am trying to figure out how to use the AXL API once exploded with the wsimport as explained here...
https://developer.cisco.com/site/collaboration/management/axl/learn/how-to/axl-java-sample-application.gsp
...to use complex types (partition, css, etc).
--> What is the correct way to do it?
Example 1: UpdatePhone
When incorporing a complex type into the addition or update of a component, for instance RoutePartitionName, DevicePoolName or CallingSearchSpaceName.
his function is not working:
public void actualizarPhone(LPhone lPhone) {
try {
UpdatePhoneReq axlParams = new UpdatePhoneReq();
axlParams.setName(lPhone.getName());
axlParams.setDescription(lPhone.getDescription());
axlParams.setDevicePoolName(lPhone.getDevicePoolName());
axlParams.setCallingSearchSpaceName(lPhone.getCallingSearchSpaceName());
StandardResponse response = axlPort.updatePhone(axlParams);
//return response.getReturn()a.toString();
} catch (Exception e) {
logger.error(e);
//return new ArrayList<LPhone>();
It seems the right thing to do set as parameter for the "set" the result of the "get" in line: setDevicePoolName(lPhone.getDevicePoolName());
but it says: "The method setDevicePoolName(JAXBElement<XFkType>) in the type UpdatePhoneReq is not applicable for the arguments (XFkType)"
Example 2: AddLine
I also have this problem when adding line.
And I've tried at least 3 approaches, no success yet:
1)** Using factory object to obtain an R object
ObjectFactory factory = new ObjectFactory();
RRoutePartition rRoutePartition = factory.createRRoutePartition();
rRoutePartition.setName("autodial");
2) ** Trying to create the demanded object: JAXBElement<XFkType> myself.
JAXBElement<XFkType> jaxbElement= new JAXBElement<XFkType>(new QName ("http://www.cisco.com/AXL/API/8.5","XRoutePartition"),XFkType.class,partition);
jaxbElement.setValue(partition3);
line.setRoutePartitionName(jaxbElement);
3)** Using X Objects
XCallForwardBusy fwdBusy = new XCallForwardBusy();
fwdBusy.setForwardToVoiceMail("true");
AddLineReq newLine = new AddLineReq();
XLine line = new XLine();
line.setAlertingName("ALerting Name");
line.setAsciiAlertingName("Alerting Name ASCII");
line.setCallForwardBusy(fwdBusy);
line.setDescription("Description");
line.setPattern("5555");
I would appreciate a clean example about how to add a line setting a partition, and an explanation about how to use JAXBElement<XFkType> objects.
regards!I am trying to figure out how to use the AXL API once exploded with the wsimport as explained here...
https://developer.cisco.com/site/collaboration/management/axl/learn/how-to/axl-java-sample-application.gsp
...to use complex types (partition, css, etc).
--> What is the correct way to do it?
Example 1: UpdatePhone
When incorporing a complex type into the addition or update of a component, for instance RoutePartitionName, DevicePoolName or CallingSearchSpaceName.
his function is not working:
public void actualizarPhone(LPhone lPhone) {
try {
UpdatePhoneReq axlParams = new UpdatePhoneReq();
axlParams.setName(lPhone.getName());
axlParams.setDescription(lPhone.getDescription());
axlParams.setDevicePoolName(lPhone.getDevicePoolName());
axlParams.setCallingSearchSpaceName(lPhone.getCallingSearchSpaceName());
StandardResponse response = axlPort.updatePhone(axlParams);
//return response.getReturn()a.toString();
} catch (Exception e) {
logger.error(e);
//return new ArrayList<LPhone>();
It seems the right thing to do set as parameter for the "set" the result of the "get" in line: setDevicePoolName(lPhone.getDevicePoolName());
but it says: "The method setDevicePoolName(JAXBElement<XFkType>) in the type UpdatePhoneReq is not applicable for the arguments (XFkType)"
Example 2: AddLine
I also have this problem when adding line.
And I've tried at least 3 approaches, no success yet:
1)** Using factory object to obtain an R object
ObjectFactory factory = new ObjectFactory();
RRoutePartition rRoutePartition = factory.createRRoutePartition();
rRoutePartition.setName("autodial");
2) ** Trying to create the demanded object: JAXBElement<XFkType> myself.
JAXBElement<XFkType> jaxbElement= new JAXBElement<XFkType>(new QName ("http://www.cisco.com/AXL/API/8.5","XRoutePartition"),XFkType.class,partition);
jaxbElement.setValue(partition3);
line.setRoutePartitionName(jaxbElement);
3)** Using X Objects
XCallForwardBusy fwdBusy = new XCallForwardBusy();
fwdBusy.setForwardToVoiceMail("true");
AddLineReq newLine = new AddLineReq();
XLine line = new XLine();
line.setAlertingName("ALerting Name");
line.setAsciiAlertingName("Alerting Name ASCII");
line.setCallForwardBusy(fwdBusy);
line.setDescription("Description");
line.setPattern("5555");
I would appreciate a clean example about how to add a line setting a partition, and an explanation about how to use JAXBElement<XFkType> objects.
regards! -
Problem in using OCIBindByName for date type column
Hi,
Can you please guide me about my following problem?
I am trying to fetch the data from system table "FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$" in Oracle Express edition 10.2.0.3 database, using the OCI library on Windows with C++
This table has a TIMESTAMP column of date type.
I've the following query as below:
select TIME_STAMP from FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$ where TIME_STAMP > to_date('31/OCT/12 23:59:59', 'DD-MON-YY HH24:MI:SS') order by TIME_STAMP asc;
For this, first I am preparing the query as below:
select TIME_STAMP from FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$ where TIME_STAMP > :PKVAL order by TIME_STAMP asc;
Before calling OCIExecute(), I am setting the PKVAL buffer to following value:
"to_date('31/OCT/12 23:59:59', 'DD-MON-YY HH24:MI:SS') "
& calling the OCIBindByName function with data type as SQLT_DATE.
But when the OCIExecute is called, my program crashes with access violation
Can you please guide me what is the correct way to pass the date value in query to OCI? How do we bind the date values?
Thanks in advance for your time and help.
Best Regards.I had a similar problem. TO_DATE doesn't appear to function w/ BindByName or BindByPos.
You are going to have to bite the bullet and use an actual date.
Here's an example (I am using two dates in my query):
int main (int argc, char **argv, char **envp)
static text invalidQuery = (text )"SELECT f1.my_val, COUNT(f1.my_val) invalid_count, (SELECT COUNT(*) FROM my_db_table f2 WHERE f2.my_val = f1.my_val AND f2.foo_dt = :1 ) total_count FROM my_db_table f1 WHERE f1.foo_dt = :1 AND ( (f1.vld_bar_sw IS NULL OR f1.vld_bar_sw = 'N') OR (f1.vld_foo_sw IS NULL OR f1.vld_foo_sw = 'N') ) group by my_val order by my_val asc";
OCIDate boundDateVal;
sb2 inputYear;
ub1 inputMonth;
ub1 inputDay;
char inputYearStr [] = "0000";
char inputMonthStr [] = "00";
char inputDayStr [] = "00";
/* I get and validate the date as input, but you can set it however you'd like */
inputYear = (sb2) (atoi (inputYearStr));
inputMonth = (ub1) (atoi(inputMonthStr));
inputDay = (ub1) (atoi(inputDayStr));
/* Allocating Date*/
OCIDateSetDate ( &boundDateVal, inputYear, inputMonth, inputDay );
OCIDateSetTime( &boundDateVal, 0, 0, 0);
returnVal = OCIBindByPos(invalidStmt, &firstInputBindHPtr, myErrorHandle, (ub4) 1,
(dvoid *) &boundDateVal, (sword) sizeof(boundDateVal),
SQLT_ODT, /*dty OCIDate*/
(dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT);
if ( !(returnVal == OCI_SUCCESS || returnVal == OCI_SUCCESS_WITH_INFO) )
displayErrors (returnVal, myErrorHandle, "OCIBindByPos-contactDate 1 ");
cleanup();
exit(1);
}//if
returnVal = OCIBindByPos(invalidStmt, &secInputBindHPtr, myErrorHandle, (ub4) 2,
//(dvoid *) &InputArguments.contactDate, (sword) sizeof(InputArguments.contactDate),
(dvoid *) &boundDateVal, (sword) sizeof(boundDateVal),
SQLT_ODT, /*dty OCIDate*/
(dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT);
if ( !(returnVal == OCI_SUCCESS || returnVal == OCI_SUCCESS_WITH_INFO) )
displayErrors (returnVal, myErrorHandle, "OCIBindByPos-contactDate 2 ");
cleanup();
exit(1);
}//if
}//main
** I have had issues w/ OTN not correctly translating certain characters, so hopefully the above example is readable or you can figure out which characters may be missing. -
Data type column size does not match size of values returned
I've tried searching but couldn't find what I was looking for, sorry if this has been answered or is a duplicate.
I am using the (Java) method below to get the column definitions of a table. I am doing this through an ODBC connection (using Oracle ODBC driver) and I have NO CHOICE in the matter.
The problem I am having is that one particular column has a column size is smaller than the size of the data it purportedly holds (ie attendance_code = varchar size 3 but data value is "Absent". I suspect the data is actually a look up to situation, where my attendance_code column has a value of 'ABS' and Oracle goes and fetchs the "Absent" value.
My issue is that the meta data returned from ODBC is the actual column definition (ie varchar(3) and not varchar2(10) for example).
The resultset metadata has a size of 3 for the column in question, and querying the schema also yields 3 for that column.
How do I resolve this? I do not have access to all_columns table etc. I have to do it using ODBC metadata only.
I've tried recreating the situation using the Oracle XE DB, but as I am not familiar with Oracle, I do not know how to recreate this scenario (which would then lead me to test other options with ODBC).
TIA.
The select I am using is SELECT * FROM <tableName>.
public ArrayList<SchemaColumn> getColumnsForTable(String catalog,
String schema,
String tableName) {
ArrayList<SchemaColumn> columns = new ArrayList<SchemaColumn>();
ResultSet rs = null;
try {
DatabaseMetaData metaData = connection.getMetaData();
rs = metaData.getColumns(catalog, schema, tableName, "%");
SchemaColumn column;
while (rs.next()) {
column = new SchemaColumn();
column.setName(rs.getString("COLUMN_NAME"));
column.setDataType(rs.getInt("DATA_TYPE"));
column.setTypeName(rs.getString("TYPE_NAME"));
column.setColumnSize(rs.getInt("COLUMN_SIZE")); <-------- this is the value that is coming back smaller than the data it actually returns
column.setDecimalDigits(rs.getInt("DECIMAL_DIGITS"));
column.setNumPrecisionRadix(rs.getInt("NUM_PREC_RADIX"));
column.setNullable(rs.getInt("NULLABLE"));
column.setRemarks(rs.getString("REMARKS"));
column.setDefaultValue(rs.getString("COLUMN_DEF"));
column.setSqlDataType(rs.getInt("SQL_DATA_TYPE"));
column.setSqlDateTimeSub(rs.getInt("SQL_DATETIME_SUB"));
column.setCharOctetLength(rs.getInt("CHAR_OCTET_LENGTH"));
column.setOrdinalPosition(rs.getInt("ORDINAL_POSITION"));
columns.add(column);
} catch (Exception e) {
Log.getLogger().error("Could not capture table schema");
closeResultSet(rs);
return columns;
}I can't say I've ever seen a case where a column held more data than it was declared as, and would have to file that under "see it to believe it" category.
Even if that somehow were the case, I'd expect the ODBC driver to return what the column is defined as anyway, not the data. The data changes with every row, but I'd expect the table metadata to be consistent, and refer to the table definition.
For grins though, can you provide system.out.println output of the metadata, and also a "describe xxxx" from sqlplus if you can, where xxx is the table name?
ie,
while (rs.next()) {
System.out.println("column name is " + rs.getString("COLUMN_NAME"));
System.out.println("data type is " + rs.getInt("DATA_TYPE"));
..etc..
Greg -
select * from table WHERE column1 = to_date(1998-12-21, 'YYYY-MM-DD')
the columns has date in the form of 1998-12-21. I am getting the following error
the error is
DB2 sql 0171n the datatype, length, or value of argument "1" of routine "to_date" is in correct sql state = 42815This is an Oracle forum.
Please take your DB2 questions elsewhere. -
I have a bad universe or a data design issue.
Several versions of hierarchies reporting store entities in reporting Fact measures.
Example of date driven Hierarchy Dimension: ORG_KEY
START_DATE
END_DATE
STORE_NUMBER
ORG_HIERARCHY
CURR_FLG (Y/N)
Fact table : ORG_KEY
CALENDAR_KEY
TRANS_DATE
$amount
Calendar Dimension: CALENDAR_KEY
DAY_DATE
FY_WEEK (201452)
FY_PERIOD (201412)
FY_QUARTER (201401)
FISCAL_YEAR (2014)
Users WISH:
Wish for store number and org hierarchy to pull as of the last day of each pull without prompt. The Store(ORG_KEY) as in the fact table; but the ORG_HIERARCHY and other attributes as of the last day they pull.
Daily (Would be Calendar.Day_Date in Filter) ,
Week to date (would be Max Calendar.Day_Date for (201452) FY_WEEK as entered,
Month to date,
Year to date,
AdHoc queries.
My problem is I see how they could manually pull this in Webi. I have tried everything I know to join to no avail. I have not gotten @Prompts to work in joins, derived tables, etc. in the data foundation. Wonder what is difference between parameter in Data foundation vs. filter in buisness layer. None of them worked.
Please help! ANY ideas would be appreciated. .{Note that abbrevations in brackets are just for short form further down the answer}
Join Store Dim (SD) to Transaction Fact (TF) on ORG_KEY=ORG_KEY with 1 to Many cardinality
Create an alias of Calendar Dim and call it Transaction Date (TD)
Join TD to TF on TD.CALENDAR_KEY=TF.CALENDAR_KEY with 1 to Many cardinality
Create a predefined condition in your universe called "Return Yesterday's Transactions" as:
TD.DAY_DATE = trunc(sysdate-1) <-- That assumes Oracle database; use whatever is correct for yesterday for your RDBMS
The above predefined condition when added to your data query will return only yesterday's transactions.
However, if you want to return all the different types of sales, you would need an object for each one. To do that, you'd use a case statement. Again, using Oracle syntax, an example of MTD would be:
SUM(CASE WHEN trunc(TD.DAY_DATE,'yyyymm') = trunc(sysdate,'yyyymm') THEN TF.amount END)
If you have any more questions about how this approach would work please shout.
As an alternative, you could create a time hierarchy and add scope of analysis to your report for it and enable drilling at report level. -
Decode in where claus with date comparasion
hi
i m using this query can we compare date in decode function in where claue if yes how
SELECT PPA.START_DATE,
PPA.END_DATE
FROM pa_project_assignments PPA,
PA_CONTROL_ITEMS PCI
WHERE DECODE(PPA.START_DATE < PCI.ATTRIBUTE1,PCI.ATTRIBUTE1,PPA.START_DATE) BETWEEN (PCI.ATTRIBUTE1) AND (PCI.DATE_REQUIRED)
AND PPA.END_DATE BETWEEN (PCI.ATTRIBUTE1) AND( PCI.DATE_REQUIRED)
AND PPA.PROJECT_ID=PCI.PROJECT_IDThis works.
SELECT * FROM emp
WHERE
CASE WHEN hiredate < SYSDATE THEN
hiredate
ELSE SYSDATE
END BETWEEN SYSDATE-10000 AND SYSDATEIn your CASE
SELECT PPA.START_DATE,
PPA.END_DATE
FROM pa_project_assignments PPA,
PA_CONTROL_ITEMS PCI
WHERE
case when PPA.START_DATE < PCI.ATTRIBUTE1 then
PCI.ATTRIBUTE1
else
PPA.START_DATE
end BETWEEN PCI.ATTRIBUTE1 AND PCI.DATE_REQUIRED
AND PPA.END_DATE BETWEEN PCI.ATTRIBUTE1 AND PCI.DATE_REQUIRED
AND PPA.PROJECT_ID=PCI.PROJECT_IDCheers!!!
Bhushan -
Use of WHERE clause to get 2 columns from dynamically generated html page.
I am using postgresql.I have to complete a java program , which is a forum like thing.User can login and submit question.....if anybody know the answer he can post the answer........Now the problem is that if more than one questions are entered it all should be displayed when we click on a "faq" button.........i created that one......these questions have the hyperlink.........When we click on a single question a text box will come........we have to write the answer there and answer should lie on the column corresponding the question clicked..............
Here i need the querry to write in servlet so that the answer is stored in the corresponding column only.................
Pleaseeeeeeeeeeeee help me as soon as possible..................
Regards
Shine..Sir,
Other than you are using postgres and a servlet I have absolutley no idea what you are on about.
Please try explaining in a less distressing manner.
Sincerely,
Slappy
Maybe you are looking for
-
How to create a PS file out of Freehand MX?
I am new to these forums, and wonder if anyone can help clarify a question: How to create a PS file with fonts embedded, out of Freehand MX? I am very late in making the transition to OSX /Freehand MX / CS1 (better late than never). Up until recently
-
Cascade SyncBos not work correctly
Hi, we have a parent SyncBo called Y01_ORD_TR and other child SyncBos Y02_ANOM. An user have a register in his mobile device, then we replicate, and this register is deleted from table merep_207. Then the user have a modification of this register and
-
Passing input id attribute to servlet
Currently my servlet is reading a form and returning the name value pairs for all of the parameters in the form. I have the following tag: <input type="text" name="First Name" id="firstnamerequired" value="<%=request.getParameter("firstname")%>">I am
-
Hi, I read that in a classical scenario, purchasers do not have to added to the purchase group in the org structure. The purchase group mereley exists to transfer the P Ggp value to the backend system. In this case if courcing is activated in the cla
-
How do I reinstall on a MAC with no disk drive?
It appears that on my work computer there is not a complete edition of ADOBE CREATIVE SUITE 5.5 DESIGN STANDARD present. I have the two original discs but the computer does not appear to have a compact disc drive. When I go to adobe on line all I see