Decode date help
hi all,
Trying to run a simple decode date check:
select T1.priority
, DECODE(T1.submitdate, (greatest(T1.submitdate, '30/06/2007')),'1') as MyCount
from table1 T1
my goal is to cross tab this so result will look like:
PRIORITY TOTAL NEW AS OF 30/06/2007
HIGH 5 1
MEDIUM 1 0
is my decode working correctly with the date range?
So I want to see for HIGH, are there "NEW" ones since 30/06/2007?
thanks!
select T1.priority, count(*) as "Total"
, CASE WHEN T1.submitdate >= to_date('30/06/2007','DD/MM/YYYY') THEN '1' ELSE '0' END as New
from table T1
hmmm, this works now but the results are not summed up??
PRIORITY TOTAL NEW
HIGH 1 1
HIGH 1 0
HIGH 1 0 .......
how do I get this?
PRIORITY TOTAL NEW
HIGH 3 1
Similar Messages
-
I'm on ios 6 beta so when I try to get ios 6 it says my software is already up to date. help?
iTunes 10.6.3 - http://support.apple.com/kb/DL1575
-
I DOWNLOADED CALIBRATED XD DECODED DEMO VERSION TO WATCH A VIDEO THAT MY QUICKTIME WOULD NOT PLAY BECAUSE IT WAS SHOT WITH XDcam AFTER WATCHING THE VIDEO I ERASED THE CALIBRATED XD...
NOW THE PROBLEM IS EVERYTIME I GO AND BURN A DVD USING TOAST THE VIDEOS ARE COVERED WITH WHITE RECTANGLES WITH THIS MESSAGE ON THEM Calibrated (Q) XD decode PLEASE HELP..CONTACT CALIBRATED TECH SUPPORT. THey can best help with the removal of the demo.
-
Changing date help icon inside a table
Dear Experts,
We changed the icon for Date help in the theme editor. In a web dynpro screen the changed image reflects for all date fields but not for the ones inside a table.
If there's a date field inside a table then the icon still shows the default imgage. We have tried to clear local as well as cluster cache and restart the protal but with no effect.
Please help in reolving this issue.
Best Regards
Gaurang DayalI think rather than trying some quirks, you are better off opening a message with SAP.
Thanks
Prashant -
Change date help icon inside table
Hello,
I've created a new theme and I've changed the date help icon(Theme Editor/Simple Elements/Labels and Fields). I can see new icon in portal but when displaying it from a cell inside a table, it displays the standard icon. Please, I need to show just our date help icon and not the standard one. It should have changed all date icons from our WD java application.
In addition, it happens the same with paginator. I've modified the Complex element: Paginator and all tables display my colours except for UWL paginator. Why UWL table is not showing the proper colours?
Thank you.I think rather than trying some quirks, you are better off opening a message with SAP.
Thanks
Prashant -
Hi it's 18th of September and I want to download iOS 7 on my ipad 4, but it says iOS 6.1.3 up to date help please.
Supposedly the rollout starts at 12:01 am ET.
Apple will be "pulsing" the release of iOS 7 to users in staggered waves according to their time zone. Thus evenly distributing the server load and ensuring that everyone that wants it can get it in a reasonable amount of time. -
Could someone else confirm this?
We are using 9i R1.
DECODE(<date field>, 'DD-MON-YYYY', , ) fails.
ie.
select decode (trunc(sysdate),'09-JUN-2003','Y','N') from dual ---> Returns 'N'
But select decode (trunc(sysdate),'09-JUN-03','Y','N') from dual ---> Returns 'Y'
Thanks,
Allan S.Can you give us an example of your tests, on my db it works in the where clause exactly the same as in the decode (and as expected).
select EMPNO, HIREDATE from EMP
where trunc(hiredate)='&1'
Enter value for 1: 22.02.1981
EMPNO HIREDATE
7521 22.02.1981
select EMPNO, HIREDATE from EMP
where trunc(hiredate)='&1'
Enter value for 1: 22.01.81
no rows selected
[pre] -
How to get up-to-date help menu in Illustrator CC?
Launching Illustrator Help in CC (International English) opens a PDF file, in which "What's new" tells me what is new in CS6 and CS5.
This does not seem right.
Is there something I can do to access the right help system for Illustrator CC?Thanks, InfluenceJamie, but I was — at the time of posting — getting a PDF, not web help. And I don't know how to restore web help.
OK, after some more digging…
Somewhere in my history of using Illustrator I've managed to switch to accessing a local PDF instead of the web-based help system — which (in its latest incarnation) is what you have linked to.
The PDF file is called "illustrator_reference.pdf", and (on my Mac) it lives in Users > Shared > Documents > Adobe > PDF > pdf.
I've just found the latest version of it online here: http://helpx.adobe.com/pdf/illustrator_reference.pdf — which has let me update the file to CC.
To see if I can return to the web based system I have tried deleting the Adobe folder mentioned above. Attempting to access Illustrator Help after that produces a dialog box that tells me I must be connected to the internet (which, of course, I am).
Restoring the Adobe folder and deleting only the PDF folder within it (leaving the other folder, entitled "Help") produces the same dialog. So I've restored the PDF folder as well.
The upshot is that I now have up to date help in PDF format on my local drive but no idea how to revert to Web help. -
Why is my texting using data? When I have data turned off I can't send/receive. Texting is "unlimited" but it's using up all my data- help!
Texting longer text messages or any media (pictures/video/sound etc) being sent requires data to be active. However, it does not count against your data caps.
Since you have an iPhone, you must also be aware of the difference between iMessage and SMS Text messages. The iPhone, by default, will send an iMessage when sending another text message to anyone else with an iPhone, iTouch, or iPad. This does use your data if you are not connected to wifi. In Settings, you can turn iMessage off, and then all of your texts will go through Verizon.
Also understand- iMessage will use wifi when connected to wifi, but would need cellular data connection to work when not connected to wifi. Regular SMS text messages that are long or any media will always use the cellular data and not wifi, so will not send if cellular data is turned off, even if on wifi. However, this does not count against your cap. -
hi all,
i have a requirement in which i have declared a inputfiled type date and getting this field filled through pop up help using the below code.
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form>
<htmlb:label for = "HDATE"
text = "From Date"
tooltip = "Enter from date" />
<htmlb:inputField id = "HDATE"
value = "<%= sy-datum %>"
showHelp = "X"
type = "date"
disabled = "FALSE" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
now i wanted to execute an additional function when the help button is clicked so i declared it in as
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form>
<htmlb:label for = "HDATE"
text = "From Date"
tooltip = "Enter from date" />
<htmlb:inputField id = "HDATE"
value = "<%= sy-datum %>"
showHelp = "X"
onValueHelp = "sapHelpDate('HDATE', parameters);function();"
type = "date"
disabled = "FALSE" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
The function sapHelpDate is the default function which is called when onValueHelp is not mentioned.
Could anyone please throw some light on this function?
by doing the above i am able to execute my separate function along with the pop up coming for the date,but the icon for the date help is changed and i am not able to show it same as in default case.
could any one help me with this.
thanks in Advance
regards,
Arvind.used BSP replace and find to replace the class and the icon was same as before
-
i try to convert to decode data to base 64 using bouncy castle lib.
after decoding i got Bizarre characters
my input data :IzIrnQA2aQbOw5ysPJJumDSspCvdwd/zec21/K+t1RlXsjid6vpNsNKVgCH5KfMIeqXFsGEKRZO/4Xd2nZYND32eSdbbqgkDFMsYK8qSFQo2gvYwHXAQg5BEvB51zldef4mr06GXldtTIZSKfGMI1WcoM92Zi9P1sfZd2hfy7zc=
out data :
#2+?�6i????<?n?4??+????y??????W?8???M????!?)?z???a
E???wv??
}?I??? ?+??
6??0p??D?u?W^???????S!??|c?g(3???????]???7
is it correct? thank you for any responsebada wrote:
Hear is the line of my code.
import org.bouncycastle.util.encoders.Base64
String decodedStr ="IzIrnQA2aQbOw5ysPJJumDSspCvdwd/zec21/K+t1RlXsjid6vpNsNKVgCH5KfMIeqXFsGEKRZO/4Xd2nZYND32eSdbbqgkDFMsYK8qSFQo2gvYwHXAQg5BEvB51zldef4mr06GXldtTIZSKfGMI1WcoM92Zi9P1sfZd2hfy7zc=";
byte[] signBytes = Base64.decode(decodedStr.getBytes("UTF-8"))
System.out.println(new String(signBytes ));
Do you see something wrong in the code.Yes. Don't convert the signBytes to a String since (reading between the lines) it is a signature which is binary data and not characters. -
TIPS(53) : DECODE를 이용한 DATE INSERT 시에 잘못된 값이 들어가는 경우.
제품 : ORACLE SERVER
작성날짜 : 2002-11-06
TIPS(53) : DECODE를 이용한 DATE INSERT 시에 잘못된 값이 들어가는 경우
=====================================================================
Purpose
decode를 사용하는 date data type의 처리에서는 가끔 예기치 않은
오류가 발생된다. 예를 들면 2000년을 insert를 하였는데 실제 값은
1900년이 들어가게 되는 문제이다. 이것은 사용자를 매우 당황하게
만드는데 이런 경우에 대해 확인하고 조치하는 방법을 살펴보자.
Problem Description
1. nls_date_format을 'yy-mon-dd'로 하였을 경우
SQL> ALTER SESSION SET NLS_DATE_FORMAT='YY-MON-DD';
SQL> CREATE TABLE TABDATE(COLDATE DATE);
SQL> INSERT INTO TABDATE(COLDATE)
SELECT DECODE('1','0',NULL,'1',(TO_DATE('200511','RRRRMM')))
FROM DUAL;
SQL> SELECT TO_CHAR(COLDATE,'YYYY-MM-DD') FROM TABDATE;
TO_CHAR(CO
1905-11-01 -- 2005년이 들어가 있어야 하는데 오동작을 했다.
2. nls_date_format을 'yyyy-mon-dd'로 하였을 경우
SQL> ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MON-DD';
SQL> INSERT INTO TABDATE(COLDATE)
SELECT DECODE('1','0',NULL,'1',(TO_DATE('200511','RRRRMM')))
FROM DUAL;
SQL> SELECT TO_CHAR(COLDATE,'YYYY-MM-DD') FROM TABDATE;
TO_CHAR(CO
1905-11-01
2005-11-01 -- 정상적인 값이 들어와 있다.
3. 문제 설명
어떻게 이런 문제가 발생하는가?
이것은 dbms가 decode를 처리하는 내부적인 절차에 의해 벌어지는 것으로
당연한 현상이다. decode를 처리할 경우 decode 안의 값이 to_date로
처리되기 이전에 varchar2로 값을 넘겨 받아서 그 결과값으로 to_date
함수에 넘겨저서 처리하게 된다.
그런데 이 경우에 to_date 함수를 처리하기 전에 data의 conversion에
이용되는 것이 시스템의 default NLS_DATE_FORMAT 값인 것이다.
그러므로, 이 값의 년도 처리가 두 자리로 되어 있을 경우 년도를 두자리
만을 처리하여 varchar2 값으로 넘기게 되고 이것을 to_date 함수를
이용하여 처리하게 되므로 우리가 예상치 못한 값이 나오게 되는 것이다.
실제 SQL이 다음과 같으면
SELECT to_char(to_date('0511','yyMM'),'yyyymmdd') FROM DUAL;
결과 값은 19051101로나오게 된다.
Solution Description
이 문제는 NLS_DATE_FORMAT의 년도가 두 자리로 지정된 경우에
decode 함수를 사용하는 date data는 오동작을 할 가능성이 있다는 것이다.
이에 대한 해결 방법은 nls_date_format의 년도를 네 자리로 지정해 주는 것이다.
이에는 세 가지 방법이 있을 것이다.
1. alter session set nls_date_format='yyyy-mm-dd';
2. 환경변수의 nls_date_format을 변경하기.
3. database 내의 nls_date_format를 변경하기.
Reference Documents
none -
Looking for some tips on Decoding date. TX
HI,I still have problem with this decode. I need to count students group by their region on each month. The output should be
COUNTRY OCT NOV DEC .....
USA 5 20 30
CAN 100 1 0
MEX 10 20 30
The date format is 5/19/2007
This is my code: and thanks for your help
WITH Q AS (SELECT DISTINCT A.STDID, A.NUMBER, A.ADMIT
FROM PROG A
JOIN CITIZEN B ON A.STDID = B.STDID
JOIN REGION_TBL C ON C.REGION = B.REGION
AND A.NUMBER = 'PS'
AND A.ADMIT IN ('2007','2008'))
SELECT J.REGION, I.DESCR,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '09', 1, 0))) SEP_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '10', 1, 0)))OCT_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '11', 1, 0)))NOV_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '12', 1, 0)) )DEC_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '1', 1, 0)) )JAN_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '2', 1, 0)) )FEB_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '3', 1, 0)) )MAR_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '4', 1, 0)) )ARL_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '5', 1, 0)) )MAY_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '6', 1, 0)) )JUN_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '7', 1, 0)) )JUL_TOTAL,
SUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '8', 1, 0)) )AUG_TOTAL
FROM CITIZEN J
JOIN PROG L ON J.STDID = L.STDID
JOIN Q ON J.STDID = Q.STDID
AND Q.NUMBER = J.NUMBER
GROUP BY J.REGION, I.DESCRSUM(DECODE(TO_CHAR(L.ACTION_DT,'YYYY-MM-DD', '09', 1, 0))) SEP_TOTAL,Apart from having brackets in the wrong place you are comparing a date that you are converting to a string in the format YYYY-MM-DD to a string that is 1 or 2 digit number.
This should be something like
SUM(DECODE(TO_CHAR(L.ACTION_DT,'MM'),'09',1,0)) as SEP_TOTAL, -
SQL Loader : Trim and Decode functions help please
Hi,
I have to load data from a flat file, for some columns i need to use TRIM and DECODE functions.It is a pipe delimited file.
I get syntax errors (one is below) same error listed for TRIM.
SQL*Loader-350: Syntax error at line xx.
Expecting "," or ")", found "DECODE".
===========
,FINAL_BILL_DATE CHAR(30) "TRIM(:FINAL_BILL_DATE)"
,BUSINESS_ID "DECODE(:BUSINESS_ID,'B',1,'C',2,'E',3,'G',4,'O',5,'R',6,'T',7,'U',8,'H',9,-1)"
Can anyone please help.
Thanks
CherrishHello Cherrish.
The error you are receiving leads me to believe that at some point prior to the DECODE on the line for BUSINESS_ID, probably some line even before the FINAL_BILL_DATE line, there a syntactical error causing the quotes before the DECODE to actually terminate some other syntax. Without all of the lines that could actually contribute to this, including the header details, this is the best I can advise.
Hope this helps,
Luke
Please mark the answer as helpful or answered if it is so. If not, provide additional details.
Always try to provide create table and insert table statements to help the forum members help you better. -
I am not able to write one query.....actually the problem is quite big..but for the sake of clarity i will putting the same in parts.
consider the following table with below mentioned colums.
MSSA_SALES
salesman
product
quantity
sal_month
The table contains rows of sales figures for different salesman/product/month.
Like
salesman product quantity sal_month
john Butter 10 01-apr-02
Smith Cheese 20 01-apr-02
John Cheese 1 01-apr-02
john Butter 10 01-dec-02
Smith Cheese 20 01-dec-02
John Cheese 1 01-dec-02
john Butter 10 01-apr-03
Smith Cheese 20 01-apr-03
John Cheese 1 01-apr-03
paul powder 53 01-aug-03
adams chocolate 43 01-aug-03
now i want the output in following format.
Butter Cheese Powder chocolate
John
aug_03 20 34 56 0
Cum_02 100 20 23 24
Cum_03 5 4 5 0
Smith
aug_03 23 44 0 34
Cum_02 11 11 11 11
Cum_03 1 2 3 4
---------------Now the requirement is-----------------
In first row it should show the value of sales for one month say 01-aug-03.
In second row it should show the value of sales cumulative i.e from 01-apr-02 to 01-mar-03.(cum_02)
In second row it should show the value of sales cumulative i.e from 01-apr-03 to 01-aug-03.(cum_03)
I am able to produce , what is required in first row and third row the problem is coming for 2nd row i.e cum_02 only.
I have written following query
select salesman,
product,sum(decode(to_char(sal_month),'01-AUG-03',wss_qty,0))
aug_03,
sum(wss_qty) cum_03
from mssav_wd_sales_summary
where sal_month between '01-apr-03' and '01-sep-03'
group by salesman,product
it will give me aug_03 and cum_03 figures but not cum_02.If i change the where condition as "where sal_month between '01-apr-02' and '01-aug-03'"then the whole outut will be wrong because cum_03 will start including the figures from 01-apr-02 , but i want it to include period from 01-apr-03 onwards only.
So please help me in designing the query.
Then i will reuqest for the second part of my problem.
Regards,
Rajeev KatyalHere is the decode version:
select
salesman, product,
sum(decode(to_date('01-aug-2003','dd-mon-yyyy'),sal_month,quantity,0)) aug_03,
sum(
decode(least(sal_month,to_date('01-apr-2002','dd-mon-yyyy')),to_date('01-apr-2002','dd-mon-yyyy'),
decode(greatest(sal_month,to_date('01-aug-2003','dd-mon-yyyy')),to_date('01-aug-2003','dd-mon-yyyy'),quantity,0),
0)
) cum_02,
sum(
decode(least(sal_month,to_date('01-apr-2003','dd-mon-yyyy')),to_date('01-apr-2003','dd-mon-yyyy'),
decode(greatest(sal_month,to_date('01-sep-2003','dd-mon-yyyy')),to_date('01-sep-2003','dd-mon-yyyy'),quantity,0),
0)
) cum_03
from
mssa_sales
group by
salesman, product
/Both queries output the same values:
SALESMAN PRODUCT NVL(AUG_03,0) NVL(CUM_02,0) NVL(CUM_03,0)
Adams Chocolate 43 43 43
John Butter 0 30 10
John Cheese 0 3 1
Paul Powder 53 53 53
Smith Cheese 0 60 20
SALESMAN PRODUCT AUG_03 CUM_02 CUM_03
Adams Chocolate 43 43 43
John Butter 0 30 10
John Cheese 0 3 1
Paul Powder 53 53 53
Smith Cheese 0 60 20BTW, note that the dates are overlapping. I take it that is your intend.
Lennert
Maybe you are looking for
-
See above question
-
My PC got infected with virus and i was using avast, intead of repairing the files it deleted them. so i had to reinstall most of the softwares. but for photoshop i had to use "adobe creative suite cleaner tool" and "adobe support advisor", but thoug
-
Another calendar sync question.
Hi, I have Mac, Macbook, Ipad and Iphone. They all share photos via icloud but I just cant find a way to make them share calendars in any way. I've read various threads but am getting nowhere. If anyone could help (in easy steps!) I'd be very gratefu
-
Suddenly, the sound on my Mac is muted. I tried to unmute using the keyboard. I can not. I went to preferences, sound and Output does not show anything available. There is no option for internal speakers or any other sound item. Mute is checked and I
-
Bookmarks pick up most recent google search and give me an error page
Started just recently, after an upgrade: I use the google tool bar and when I click on one of the buttons (essentially a bookmark) Firefox automatically tags on to the bookmarked URL the most recent google search. For instance http://www.google.com/s