Can i use or in decode
hi master
sir see my query
select decode((sum(debit)-sum(credit)),sum(debit)>sum(credit),(sum(debit)-sum(credit)),
sum(credit)-sum(debit),(sum(credit)-sum(debit))),title form transction group by title
means i can use < or > in decode
thank aamir
You use sign function for yours require task
For example you check if a b > 10 the display a else display b.
Decode (Sign(a-b), 1, A,
,-1, B, 0)
Best regards
R E H A N M I R Z A
Similar Messages
-
JSF 2 composite comp. backing class: what can I use for the decode method?
Hello, everybody!
I want to convert a JSF 1.2 custom component to a JSF 2.0 composite component. This JSF 1.2 custom component uses a renderer where I take some actions in the decode method. So, I would like to know what I could use to replace the well known decode method when writing a backing class for a JSF 2.0 composite component.
Thank you.
Marcos
Edited by: Marcos_AntonioPS on May 21, 2010 11:59 AMLet's try with org.havi.ui.HStaticText
-
Can i use Decode in Where clause
Hi,
Can i use Decode in Where clause Please Do the need full on the same.
Thanks,
Sanjeev.set serveroutput on
DECLARE
posn PLS_INTEGER := 0;
empid PLS_INTEGER := 178;
x NUMBER;
BEGIN
SELECT NVL(SUM(ah.quantity * ah.saleprice * ap.payoutpct), 0)
INTO x
FROM accessoryhistory ah, payoutpercentage ap,
sku s, store st
WHERE empid = DECODE(posn,
0, st.areadir,
1, st.areamgr,
2, NVL(st.storemgr1, st.storemgr2),
3, NVL(st.asstmgr1, NVL(st.asstmgr2,
st.asstmgr3)))
AND ah.statustype IN ('ACT', 'DEA')
AND ah.store = st.store
AND s.dbid = ah.dbid
AND s.sku = ah.sku
AND ap.productgroup = s.productgroup
AND ap.position = posn;
dbms_output.put_line(x);
END;
/http://psoug.org/reference/decode_case.html -
Can I use decode( decode...)...)
Hi,
Can I use decode function inside decode function.
It seem doesn't work. Please help
decode(lv.RANK||' / '||
decode('('||lv.ONE_YR_PCT||'%)', '(%)','N/A','('||lv.ONE_YR_PCT||'%)'),
'0 / (0%)','N/A', lv.RANK )
ThanksI'm not quite sure it's the result you intended but your nested decode statement does run ...
SQL> CREATE TABLE lv (rank number, one_yr_pct number)
2 /
Table created.
SQL> insert into lv values (1, 1)
2 /
1 row created.
SQL> insert into lv values (2,2)
2 /
1 row created.
SQL> insert into lv values (0,0)
2 /
1 row created.
SQL> select decode(lv.RANK||' / '||
2 decode('('||lv.ONE_YR_PCT||'%)', '(%)','N/A','('||lv.ONE_YR_PCT||'%)'),
3 '0 / (0%)','N/A', lv.RANK )
4 from lv
5 /
DECODE(LV.RANK||'/'||DECODE('('||LV.ONE_
1
2
N/A
SQL> If you're having problems maybe you should cut'n'paste the output from your SQL*Plus session so we can see what's happening.
Alternatively, as CD suggests, you may find it easier to express your logic using CASE.
Cheers, APC -
Can we use IF statement in PDF templates
Hi,
I developed a PDF template. I need to underline ang bold the records based on a specific condition. Can we use IF conditon in PDF templates. Please suggest.
Thanks...Billy Verreynne wrote:
The case syntax is a bit funny though as there's not a single condition evaluation (like a DECODE or case structs from some other languages).
This is what I would expect a typical case struct to look like - evaluating a single condition:
case <condition>
when <value-1> then return <result-1>
when <value-n> then return <result-n>
else
return <return-z>
end
?:| You mean like this...?
SQL> ed
Wrote file afiedt.buf
1 select empno, ename, deptno
2 ,case deptno
3 when 10 then 'This is Department 10'
4 when 20 then 'And department 20'
5 when 30 then 'And of course department 30'
6 else
7 'Blimey it is something else!'
8 end as dept_desc
9* from emp
SQL> /
EMPNO ENAME DEPTNO DEPT_DESC
7369 SMITH 20 And department 20
7499 ALLEN 30 And of course department 30
7521 WARD 30 And of course department 30
7566 JONES 20 And department 20
7654 MARTIN 30 And of course department 30
7698 BLAKE 30 And of course department 30
7782 CLARK 10 This is Department 10
7788 SCOTT 20 And department 20
7839 KING 10 This is Department 10
7844 TURNER 30 And of course department 30
7876 ADAMS 20 And department 20
7900 JAMES 30 And of course department 30
7902 FORD 20 And department 20
7934 MILLER 10 This is Department 10
14 rows selected. -
How can i use one SQL statement to solve problem?
How can i use one SQL statement to solve the question below?
For a Table named A, there is a column named F(char type).
Now select all the records where F like '%00' and update their F value to '%01'
Just one SQL statement.Do not use PL/SQL block.
How to do that?
Thanks.What is the data volume for this table?
Do you expect lots of rows to have '%00' as their value?
Following two statements come to mind. Other experts would be able to provide better alternatives:
If you have index on SUBSTR(f, 2):
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) || '01'
WHERE substr(f,
-2) = '00';If most of the rows have pattern '%00':
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) ||
DECODE(SUBSTR(f,
-2),
'00',
'01',
SUBSTR(f,
-2)); -
Can we use replace function in bursting control file?
Hi All,
Greetings!!!!!!!!!!
Have a doubt can we use sql functions like replace,nvl,decode.. in xml bursting control file.
Please let me know if there is a option.
awaiting reply...
Thanks
RajeshIn Expression operator or in Filter, etc. you can type function name by hand.
Oleg -
Use sql function decode with Zend code
Hi,
I need to use sql function DECODE() in a query for PHP Code. This query works well in sql*plus but PHP returns
the following error message:
Parse error: syntax error, unexpected T_STRING in C:\Program Files\Zend\Apache2\htdocs\Compta\compta2.php on line 16
the query is :
$query =
'select substr(c.NUM,1 ,2) Compte ,
c.designation , a.Periode
,decode(substr(c.NUM,1 ,1), '1',1, '2',1,'3',1,-1) cp_type ,
sum(credit) - sum(debit) Montant
from ecritures a, clients b, compte c
where
b.NUM (+) =a.NUM
and a.DATEECRITURE between to_date(:debut, \'dd/mm/yy\') and to_date(:fin, \'dd/mm/yy\')
and substr(a.num,1,2) =c.num
group by substr(c.NUM,1 ,1), substr(c.NUM,1,2) , c.designation ,a.periode
order by compte ';
Can any one help me ???
Thanks by advance
nb: Iuse Zend 2.0Hi,
You need to escape single quote mark:
decode(substr(c.NUM,1 ,1), \'1\',1, \'2\',1,\'3\',1,-1) cp_type ,
the same way you did for to_date:
to_date(:debut, \'dd/mm/yy\')
Regards,
Paweł -
Can we use Case in Where Clause along with Exists
Hi Everybody,
Can we use Case in the where clause with exists? As i have a requirement in which i have to check whether value exists in 6 views, now depending on some value(gns_type )of select clause i have to attach a paticular exists else the performance dies.
Please go through the query any suggestion appreciated.
Thanks
SELECT count(*)
FROM
(SELECT eah.changed_date,
decode(eua.is_deleted, 'N', decode(eah.alert_type, NULL, 'GN', 'R', 'GAR', 'G', 'GAG', 'Y', 'GAY'), 'Y', decode(eah.alert_type, 'R', 'GDR', 'G', 'GDG', 'Y', 'GDY', NULL, 'GN'), NULL, 'GN') AS
alert_type,
decode(eac.pta_line, 'N', '') ptaline,
eac.exp_type_desc,
eac.supplier_name,
eac.transaction_id,
eah.gns_type,
eac.po_amount,
eac.po_end_date,
eah.notes,
eua.is_deleted,
eac.expenditure_type,
eua.gns_alert_summary_id,
eah.changed_date alert_date,
eua.user_alert_id,
eah.reference_number,
decode(eac.cms_pta_line,'N','',eac.cms_pta_line) cms_pta_line,
cms_po_amount,
cms_po_end_date,
mgns.is_decommitted,
eac.gns_alert_id,
eah.gns_type source_name
FROM xxdl.xxdl_sc_gns_alerts_summary eah,
xxdl.xxdl_sc_gns_detail_alerts eac,
xxdl.xxdl_sc_gns_user_alerts eua,
xxdl.xxdl_sc_manage_gns_master mgns
WHERE eah.gns_alert_summary_id = eac.gns_alert_summary_id
AND eah.gns_alert_summary_id = eua.gns_alert_summary_id
AND eah.transaction_id = eac.transaction_id
AND eah.transaction_id = mgns.transaction_id)
a
WHERE(EXISTS
(SELECT 1
FROM xxdl_sc_mng_gns_pta_req_hc_v x
WHERE x.transaction_id = a.transaction_id
AND x.source_name = a.source_name
AND x.project_id = 69309
AND x.task_id = 242528
AND x.award_id = 34694)
OR
EXISTS( SELECT 1
FROM xxdl_sc_mng_gns_pta_inv_hc_v x
WHERE x.transaction_id = a.transaction_id
AND x.source_name = a.source_name
AND x.project_id = 69309
AND x.task_id = 242528
AND x.award_id = 34694)
OR
EXISTS(SELECT 1
FROM xxdl_sc_mng_gns_pta_req_sc_v x
WHERE x.transaction_id = a.transaction_id
AND x.source_name = a.source_name
AND x.project_id = 69309
AND x.task_id = 242528
AND x.award_id = 34694)
OR
EXISTS(SELECT 1
FROM xxdl_sc_mng_gns_pta_inv_sc_v x
WHERE x.transaction_id = a.transaction_id
AND x.source_name = a.source_name
AND x.project_id = 69309
AND x.task_id = 242528
AND x.award_id = 34694)
OR
EXISTS( SELECT 1
FROM xxdl_sc_mng_gns_pta_po_sc_v x
WHERE x.transaction_id = a.transaction_id
AND x.source_name = a.source_name
AND x.project_id = 69309
AND x.task_id = 242528
AND x.award_id = 34694)
OR
EXISTS (SELECT 1
FROM xxdl_sc_mng_gns_pta_po_hc_v x
WHERE x.transaction_id = a.transaction_id
AND x.source_name = a.source_name
AND x.project_id = 69309
AND x.task_id = 242528
AND x.award_id = 34694)
AND TRUNC(alert_date) >= TRUNC(add_months(sysdate, -1))
AND TRUNC(alert_date) <= TRUNC(sysdate)
AND is_deleted = 'N'
ORDER BY changed_date DESCyou can do
WHERE
CASE WHEN (something) THEN
CASE WHEN EXISTS (SELECT * from ...) THEN 1 ELSE 0 END
WHEN (something else) THEN
CASE WHEN EXISTS (SELECT * from ...) THEN 1 ELSE 0 END
END = 1Looking at your current query, it looks like all those exist statements could be a lot neater, maybe like:
WHERE (69309,242528,34694) IN
(SELECT project_id,task_id,award_id FROM
(Select project_id,task_id,award_id,transaction_id,source_name
FROM
xxdl_sc_mng_gns_pta_req_hc_v
UNION ALL
Select project_id,task_id,award_id
xxdl_sc_mng_gns_pta_inv_hc_v
...) x
where a.transaction_id = x.transaction_id
and a.source_name = x.source_name
)or put the tuple in the where clause at the bottom -
Can I use my macbook as a phone?
Can I use it fo free? My location USA MD
By the way, I dont have a sound, running DIVX, AVI files, And my luck, I have at my Macbook ( I am sorry I am a beginenr in Apple, and I am so exited!) optical audio port, and some oval shape port - I even dont know, what is that. But I need some codec, or filter to run that format movies with DTS 5.1 Soraunnd sound decoding.
Thank you very much! -
I want to count several categories(say a b c d) under same count and some catogories under another count ..there I need to use count with decode pls let me know the syntacs to write my query..this is ergent
regards
BuddhikeSomething like this ?
select count(decode(your_column,'a',1)) as "a",
count(decode(your_column,'b',1)) as "b",
count(decode(your_column,'c',1)) as "c",
count(decode(your_column,'d',1)) as "d"
from your_table;But maybe you can give us more details about what do you expected ?
Nicolas. -
Hello,
My requirement is that I have 2 poplists - Country and States.
When I select a country,the corresponding states of that country should get populated in the states poplist.
The approach I took is that :
I selected firePartialAction as ActionType in Country poplist. Then I called a function to VOImpl of StatesVO and set the where clause there.
Now I was thinking about using decode as there is no direct connection between the CountryVO and StatesVO.
Is it possible to use functions like decode in 'setWhereClause()'?
For Example:
setWhereClause("DECODE(LOOKUP_TYPE,'XXC_IND_STATES','IND','XXC_US_STATES','US') = :1");
setWhereClauseParam(0,Country);
executeQuery();
When I tried running the page,no error was given but when the country poplist was changed - there is no change in states poplist.
If its not possible to use decode in setWhereClause(), could you please guide me as to how I can write a query to retrieve a value from a table and store it in a variable 'A'- so that I can pass that variable 'A' in setWhereClauseParam function .
Message was edited by:
Anju SusanThat kewl, but for u knowledge u can add anything in ur where clause of query through ur code in Voimpl class. It is even possible to do change entire query, see Voimpl class methods in javadoc.
--Mukul -
How to use XVID MEPG4 DECODER in labview
May i ask how to use Xvid MEPG4 Decoder to compress the AVI file. For this decoder have been installed in my computer but the VI(IMAQ AVI2 Get Codec Names)can not list this code name. So may i ask how can i use this decoder in the labview. For this decoder is relatively has good quality and also small size. Or what kind of other solution can be provieded for the relative small size of AVI file.
Thanks
DanielI believe this was answered already in a different thread: http://forums.ni.com/t5/LabVIEW/LabView-to-grab-and-save-video-to-mpeg/m-p/643864
www.movimed.com - Custom Imaging Solutions -
Can I use JMS instead of multithreaded approach
Hi,
I am having a typical problem where the XML data coming through sockets using TCP/IP needs to be read and perform some action.
The code I have uses two classes to do this, each of them extending the Thread class, and invokes the individual run() method. In the run() method the second class's constructor is called which in turn invokes its own run() method. In the second run() method a handler method is invoked which does the required function. The dedicated threading approach is required in my application but my question is:
1. Instead of achieving the handling using threading, which seems to be a bit complex, can I write a JMS listener and queue the XML messages in a Oracle database. ( I am using Oracle 9i (Advance Queue can be used)).
2. Will using JMS will increase the overall performance any way?
PLease help!!
regards
KaushikThe JMS does the threading for you. This would potentially make your application simpler but you still need a thread(s) at the end of the day in the same way.
The JMS is a more comprehensive package which hides much of the work for you. It also does alot of work which is not needed. For this reason I would expect JMS to be slower than a well written custom implementation. However, typically JMS is fast enough and much more maintainable, easily reconfigured etc. etc. and CV++ :)
My guess is that most of your work is in decoding your XML data or somewhere you don't expect.
If you want it to go faster I would suggest getting a profiler e.g. JProfiler on demo license and do some performance tests. You will probilbly find there a few simple things you can do to improve performance.
I would not concider the kind of migration you suggest until you know expectly what the problem is. You can waste alot of time optimising code which was not a problem in the first place. (: from experience :) -
How can i use analytic function on these data
hi ,
i have the following data:
id start end
1 11-oct-2006 03:00:34 12-oct-2006 09:00:10
1 09-oct-2006 05:00:23 11-oct-2006 03:00:34
1 08-oct-2006 03:00:23 09-oct-2006 05:00:23
2 11-oct-2006 11:00:00 11-oct-2006 14:00:00
1 08-oct-2006 03:00:00 08-oct-2006 04:00:00
my end results shld be
id start end
1 08-oct-2006 05:00:23 12-oct-2006 09:00:10
2 11-oct-2006 11:00:00 11-oct-2006 14:00:00
1 08-oct-2006 03:00:00 08-oct-2006 04:00:00
pls advise
tks & rdgsMohana ,
I think Elic's solution can be used here also
(Group by preserving the order
sql>select * from t;
ID ST ED
1 11-OCT-06 03.00.34.000000 AM 12-OCT-06 09.00.10.000000 AM
1 09-OCT-06 05.00.23.000000 AM 11-OCT-06 03.00.34.000000 AM
1 08-OCT-06 04.00.23.000000 AM 09-OCT-06 05.00.23.000000 AM
2 11-OCT-06 11.00.00.000000 AM 11-OCT-06 12.00.00.000000 PM
1 08-OCT-06 03.00.00.000000 AM 08-OCT-06 04.00.00.000000 AM
sql>
select id,min(st) st,max(ed) ed
from(
select id,st,ed, sum(grp) over(order by st) sm
from(
select id,st,ed,decode(lag(ed) over(order by st),st,0,1) grp
from t))
group by id,sm;
ID ST ED
1 08-OCT-06 03.00.00.000000 AM 08-OCT-06 04.00.00.000000 AM
1 08-OCT-06 04.00.23.000000 AM 12-OCT-06 09.00.10.000000 AM
2 11-OCT-06 11.00.00.000000 AM 11-OCT-06 12.00.00.000000 PM
Message was edited by:
jeneesh
Maybe you are looking for
-
How to automate the WM/shipping process after the consignment issue ?
I am looking for the best way to automate the shipping process after the consignment issue orders has been created. since Warehouse/shipping process will not consist of any actual picking and shipment but we are still required to go through the use o
-
Terminal echo is off after interrupting cvs password entry (:ext, ssh)
situation: set CVSROOT=:ext:username@servername:/dir The "ext" is important. You can set up a local cvsroot dir, do a "cvs init" there and then use localhost as server. This bug occured to me on several servers so it is not server dependent. set CVS_
-
EBS - fill assignment field with bank reference
Hi, We are trying to fill the bank reference for incoming payments in the assignment field for the GL postings. For the 2 banks it is working fine, since they send it in 88 record and we have defined search string to fill in assignment field. We use
-
WCF RIA wrapper for SOAP service that is compatible with Lightswitch Data Source
I have a WCF RIA wrapper around a SOAP service and all the simple entities work just fine. Unfortunately Lightswitch does not like my represenation of complex entities like SalesInvoice that contains a list of SalesInvoiceLines. How should I represen
-
Setting defaults at Responsibilty level
Hi, Can we set the default values to the attributes at different levels say site level,responsibility level. Regards Ashwini