SQL equivalent of if-statement
What would be really useful would be if I could do an SQL equivalent of an if-statement. I'm just making the following up to show what I mean:
SELECT CASE
WHEN(det.user_entity_name = 'PO Header')
THEN (SELECT pha.segment1
FROM po.po_headers_all pha
WHERE pha.po_header_id = ad.pk1_value)
WHEN(det.user_entity_name = 'PO Line')
THEN (SELECT pha.segment1
FROM po.po_headers_all pha
, po.po_lines_all pla
WHERE pha.po_header_id = pla.po_header_id
AND pla.po_line_id = ad.pk1_value)
ELSE 'UNDEFINED'
END doc_num
, ad.seq_num
, fu.description created_by
, dt.description
, det.user_entity_name
, ad.creation_date
, ad.entity_name
, ad.pk1_value
if dat.user_name = 'Short Text' then
dst.short_text
elseif dat.user_name = 'Long Text' then
dlt.long_text
end if
FROM applsys.fnd_document_datatypes dat
, applsys.fnd_document_entities_tl det
, applsys.fnd_documents_tl dt
, applsys.fnd_documents d
, applsys.fnd_document_categories_tl dct
, applsys.fnd_attached_documents ad
if dat.user_name = 'Short Text' then
, applsys.fnd_documents_short_text dst
elseif dat.user_name = 'Long Text' then
, applsys.fnd_documents_long_text dlt
end if
, applsys.fnd_user fu
WHERE d.document_id = ad.document_id
AND dt.document_id = d.document_id
AND dct.category_id = d.category_id
AND d.datatype_id = dat.datatype_id
AND ad.entity_name = det.data_object_code
if dat.user_name = 'Short Text' then
AND dt.media_id = dst.media_id(+)
elseif dat.user_name = 'Long Text' then
AND dt.media_id = dlt.media_id(+)
end if
AND ad.created_by = fu.user_id
AND d.creation_date > '01-OCT-2007'
if dat.user_name = 'Short Text' then
AND dat.user_name = 'Short Text'
elseif dat.user_name = 'Long Text' then
AND dat.user_name = 'Long Text'
end if
AND dct.user_name = 'To Supplier';Is that possible, or am I just talking a load of nonsense?
Thanks
How to do IF in SQL:
1) CASE
2) DECODE
3) UNION, UNION ALL, MINUS, INTERSECT
4) AND + OR + ()
5) stored functions
6) ...
which is best just depends on the situation. For your example I would use decode in the select clause and some UNION ALL for the from/where clauses.
Similar Messages
-
Does ORCALE have the Equivalent of the SQL SERVER 2K GO Statement?
Good morning Oracle Gurus,
I have an easy one for you. In SQL Server 2k you can write a "block" of SQL and then add a GO statement to the next line and then add another "block" of SQL. The GO statement will cause the first block of SQL to be executed before the second block. Is there any such statement in Oracle that will allow me to do the same thing?
Thanks in advance for you help!As previously mentioned you can use slash "/"
SQL> insert into t
2 select *
3 from emp
4 /
14 rows created.
SQL> select *
2 from t
3 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 12-17-1980 800 20
7499 ALLEN SALESMAN 7698 02-20-1981 1600 300 30
7521 WARD SALESMAN 7698 02-22-1981 1250 500 30
7566 JONES MANAGER 7839 04-02-1981 2975 20
7654 MARTIN SALESMAN 7698 09-28-1981 1250 1400 30
7698 BLAKE MANAGER 7839 05-01-1981 2850 30
7782 CLARK MANAGER 7839 06-09-1981 2450 10
7788 SCOTT ANALYST 7566 12-09-1982 3000 20
7839 KING PRESIDENT 11-17-1981 5000 10
7844 TURNER SALESMAN 7698 09-08-1981 1500 0 30
7876 ADAMS CLERK 7788 01-12-1983 1100 20
7900 JAMES CLERK 7698 12-03-1981 950 30
7902 FORD ANALYST 7566 12-03-1981 3000 20
7934 MILLER CLERK 7782 01-23-1982 1300 10
14 rows selected.Or a semi-colon ";" to end a statement
SQL> insert into t
2 select *
3 from emp;
14 rows created.
SQL> select *
2 from t;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 12-17-1980 800 20
7499 ALLEN SALESMAN 7698 02-20-1981 1600 300 30
7521 WARD SALESMAN 7698 02-22-1981 1250 500 30
7566 JONES MANAGER 7839 04-02-1981 2975 20
7654 MARTIN SALESMAN 7698 09-28-1981 1250 1400 30
7698 BLAKE MANAGER 7839 05-01-1981 2850 30
7782 CLARK MANAGER 7839 06-09-1981 2450 10
7788 SCOTT ANALYST 7566 12-09-1982 3000 20
7839 KING PRESIDENT 11-17-1981 5000 10
7844 TURNER SALESMAN 7698 09-08-1981 1500 0 30
7876 ADAMS CLERK 7788 01-12-1983 1100 20
7900 JAMES CLERK 7698 12-03-1981 950 30
7902 FORD ANALYST 7566 12-03-1981 3000 20
7934 MILLER CLERK 7782 01-23-1982 1300 10
14 rows selected.
SQL> -
T-SQL Equivalent For Group_Concat() Function
Hello, I am looking for a way to do the MSSQL T-SQL equivalent of the MySQL aggregate function: group_concat().
We are running SQL 2005 Express. Is there a pure T-SQL way to do this, or if not, a way to create a new custom aggregate function?
EX:
SELECT GROUP_CONCAT(FIRST_NAME) AS STUDENT_LIST FROM STUDENTS GROUP BY TEACHER
OUTPUT:
JOSH,JOEY,MARK,LINDA,PAM,BILL,MIKE,JUSTINCan anyone help me with MS SQL equivalent code for below MySQL statement.
select group_concat
(Col1
order
by field(Col2,8,13,15,53,55,6,73,75,3,42,41,45,44))
as FinalColumn from TestTable
Any help is greatly appriciated... thanks in advance... -
Hello,
I've encountered issue during installation of SP1 to SQL Server 2012. After upgrade I'm getting this error in Event Log:
Script level upgrade for database 'master' failed because upgrade step 'msdb110_upgrade.sql' encountered error 537, state 3, severity 16. This is a serious error condition which might interfere with regular operation and the database will be taken offline.
If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script
upgrade steps run to completion.
Can someone point me direction how I can fix it? This is a production server and currently only way to make it working is to use T902 flag in SQL Server startup params. I've found some suggestions to check Data path if it exists but it does so this is not
the issue here. Any ideas?
I've found also here
http://www.sqlservercentral.com/Forums/Topic1377073-1550-1.aspx#bm1378279
suggestions for similar issue with SQL Server 2008 which that I should do:
Via ssms:
From msdb:
Delete:
dc_admin role
Dc_operator role
Dc_proxy role
UlitityCMRReader role
UtilityIMRReader role
UtilityIMRWriter role
but for not I didn't tried it yet. This is standalone SQL Server instance.
Any help really appreciated.
RegardsScript returns the same error.
System databases:
1 1 760 -1 10 1048578 0 1 master C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\master.mdf
2 0 12768 -1 10 1048642 0 1 mastlog C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
1 1 1024 -1 10 1048578 0 2 tempdev C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\tempdb.mdf
2 0 64 -1 10 1048642 0 2 templog C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\templog.ldf
1 1 288 -1 128 2 0 3 modeldev C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\model.mdf
2 0 4464 -1 10 1048642 0 3 modellog C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\modellog.ldf
1 1 28936 -1 10 1048578 0 4 MSDBData C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MSDBData.mdf
2 0 3352 268435456 10 1048642 0 4 MSDBLog C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MSDBLog.ldf
are all in place where path shows.
Before sending my message I've searched update script for "FROM master.sys.master_files" and I found script which you are showing me. I've made some digging and when I runned:
SELECT physical_name
FROM master.sys.master_files
WHERE (name = N'master')
it returned also path to one my customers database name which has filename set correctly but it's Logical DB name is master and mastlog. I'm running shared hosting company and I allow my customers to restore their DBs from .bak files but I have no idea why
this customers logical name is set to master and mastlog. Probably when I change this names update script will work as it should. On the other hand in my opinion there should be some kind of fail safe mechanism for situations like this one.
EDIT: After changing logical name for DB and log for mentioned DB your script runned fine so probably now when I remove T902 flag and restart my SQL Server update will run correctly. Big thanks for resolving this issue. -
PL/SQL equivalent for networkdays function
Hi,
Is anyone aware of a PL/SQL equivalent for the Excel "networkdays" function, that returns the number of whole workdays between 2 dates?
Thanks!
PhilTo calculate the number of days between january 1st and today, use the following.
1* select trunc(sysdate) - trunc(to_date('01-jan-05')) from dual
SQL> /
TRUNC(SYSDATE)-TRUNC(TO_DATE('01-JAN-05'))
58 -
XML SQL format for Prepared statements in batch mode
Hi
I want to use the batch mode in JDBC adapter for inserting huge volume of records with better performance.
so i need to execute the prepared statements in one batch. Is the XML SQL format for prepared statements below correct ?to<root>
<stmt>
<Customers action="SQL_DML">
<access> INSERT INTO Customers (CompanyName,Address,CustomerID) VALUES($NAME$,$ADDRESS$,$KEYFIELD$)
</access>
<key>
<NAME>IBM</NAME>
<ADDRESS>Street 3 </ADDRESS>
<KEYFIELD>CO</KEYFIELD>
</key>
<key>
<NAME>PWC</NAME>
<ADDRESS>Street 4 </ADDRESS>
<KEYFIELD>NO</KEYFIELD>
</key>
</Customers>
</stmt>
</root>
Please adviseHello Experts
Please throw some light on the above question.
Thanks in advance. -
SP2-0642: SQL*Plus internal error state 2133, context
Hi Everybody
I am getting the below wired error msg in SQL Plus when trying to execute a select statment on a external table
SP2-0642: SQL*Plus internal error state 2133, context 0:0:0
Unsafe to proceed
SP2-0642: SQL*Plus internal error state 2221, context 4294967295:4:0
Unsafe to proceed
Kindly help me out to solve this issue.
Thanks & Regards
Chandra Sekar A.
[email protected]Hi Guys
Thanks for both of you for your replies.
The problem is still pertaining.
Below is the structure I have used to create the external table
CREATE TABLE "Z_TBN_JXPKIREC"
"ORG" NUMBER ,
"ACCT" VARCHAR2(19) ,
"XD_REC_NBR" NUMBER ,
"XD_REC_TYPE_KEY" NUMBER ,
"LOGO" Number ,
"XD_DATE_LAST_MAINT" NUMBER ,
"XD_PLAN_NBR" NUMBER ,
"XD_FILLER_1" VARCHAR2(21) ,
"XD_DATE_ADDED" NUMBER ,
"XD_PRIN_BNP" NUMBER ,
"XD_INT_BNP" NUMBER ,
"XD_INS_BNP" NUMBER ,
"XD_NSF_BNP" NUMBER ,
"XD_SVC_CHG_BNP" NUMBER ,
"XD_LATE_CHG_BNP" NUMBER ,
"XD_MEMBER_BNP" NUMBER ,
"XD_OVLM_BNP" NUMBER ,
"XD_RECV_BNP" NUMBER ,
"XD_COLL_BNP" NUMBER ,
"XD_USER_FEE_1_BNP" NUMBER ,
"XD_USER_FEE_2_BNP" NUMBER ,
"XD_USER_FEE_3_BNP" NUMBER ,
"XD_USER_FEE_4_BNP" NUMBER ,
"XD_USER_FEE_5_BNP" NUMBER ,
"XD_USER_FEE_6_BNP" NUMBER ,
"XD_FILLER_2" NUMBER ,
"XD_FILLER_3" VARCHAR2(85)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY LOC_TARGET
ACCESS PARAMETERS (
RECORDS FIXED 2500
CHARACTERSET JA16EBCDIC930
STRING SIZES ARE IN BYTES
NOBADFILE
NODISCARDFILE
LOGFILE 'XXXX_9.LOG'
FIELDS
NOTRIM
"ORG" POSITION (1:3) INTEGER EXTERNAL ,
"ACCT" POSITION (4:22) CHAR(19) ,
"XD_REC_NBR" POSITION (23:25) INTEGER EXTERNAL ,
"XD_REC_TYPE_KEY" POSITION (26:27) INTEGER EXTERNAL ,
"LOGO" POSITION (28:30) INTEGER EXTERNAL ,
"XD_DATE_LAST_MAINT" POSITION (31:34) DECIMAL(7,0) ,
"XD_PLAN_NBR" POSITION (35:37) INTEGER EXTERNAL ,
"XD_FILLER_1" POSITION (42:62) CHAR(21) ,
"XD_DATE_ADDED" POSITION (38:41) DECIMAL(7,0) ,
"XD_PRIN_BNP" POSITION (63:71) DECIMAL(17,0) ,
"XD_INT_BNP" POSITION (72:80) DECIMAL(17,0) ,
"XD_INS_BNP" POSITION (81:89) DECIMAL(17,0) ,
"XD_NSF_BNP" POSITION (90:98) DECIMAL(17,0) ,
"XD_SVC_CHG_BNP" POSITION (99:107) DECIMAL(17,0) ,
"XD_LATE_CHG_BNP" POSITION (108:116) DECIMAL(17,0) ,
"XD_MEMBER_BNP" POSITION (117:125) DECIMAL(17,0) ,
"XD_OVLM_BNP" POSITION (126:134) DECIMAL(17,0) ,
"XD_RECV_BNP" POSITION (135:143) DECIMAL(17,0) ,
"XD_COLL_BNP" POSITION (144:152) DECIMAL(17,0) ,
"XD_USER_FEE_1_BNP" POSITION (153:161) DECIMAL(17,0) ,
"XD_USER_FEE_2_BNP" POSITION (162:170) DECIMAL(17,0) ,
"XD_USER_FEE_3_BNP" POSITION (171:179) DECIMAL(17,0) ,
"XD_USER_FEE_4_BNP" POSITION (180:188) DECIMAL(17,0) ,
"XD_USER_FEE_5_BNP" POSITION (189:197) DECIMAL(17,0) ,
"XD_USER_FEE_6_BNP" POSITION (198:206) DECIMAL(17,0) ,
"XD_FILLER_2" POSITION (207:215) DECIMAL(17,0) ,
"XD_FILLER_3" POSITION (216:300) CHAR(85)
LOCATION (LOC_TARGET: 'XXXX.DAT')
REJECT LIMIT UNLIMITED
NOPARALLEL
and w.r.t. SQL Plus version itz 9.2 and the database server is also 9.2
Your replies are highly appreciated and thanks for your valuable time.
Thanks & Regards
Chandra Sekar A.
[email protected] -
Hi all
I got the following error while starting a database.please help me
SP2-0642: SQL*Plus internal error state 2286, context 0:0:0 Unsafe to proceedHi,
Please look at the notes.
SP2-0642: SQL*Plus Internal Error State 2130 ORA-24315: Illegal Attribute Type [ID 1060880.1]
"SP2-0642: SQL*Plus internal error state 2090, context 0:0:0" Error Encountered While Running Select Statement [ID 555757.1]
SP2-0642: SQL*Plus internal error state 2090, context 0:0:0" Error Encountered While Running Select Statement [ID 555757.1]
They are either Windows related or general.
Regards, -
Hi,
I need to show the hierarchy of account types. The parent child relationship is stored in account type table. For eg,
acc1 child is acc2 and acc3, acc2 child is acc4. So the children for acc1 is acc2,acc3,acc4.
I am able to do so in oracle db using below query:
select connect_by_root(account_type_id) root_id, account_type_name,account_type_id, parent_type_id
from account_types
connect by prior account_type_id = parent_type_id
I am not able to create the query for MS SQL, can anyone help me to convert above oracle query to MS SQL equivalent?1. It is not MS SQL forum. Most of people here does not know MS SQL.
2. little googling helps: Recursive Queries Using Common Table Expressions http://msdn.microsoft.com/en-us/library/ms186243%28v=sql.105%29.aspx -
Equivalent Analytical SQL equivalent
DB version: 10Gr2
Is there any analytical SQL equivalent of the below ANSI SQL
select schemaname, count(*)
from v$session
group by schemaname
order by count(*) descHi,
Sure.
It's less efficient than GROUP BY, but here's one way to do it:
SELECT DISTINCT schemaname
, COUNT (*) OVER (PARTITION BY schemaname) AS cnt
FROM v$session
GROUP BY schemaname
ORDER BY cnt DESC
;"GROUP BY scemaname" produces one row per value of schemaname; without GROUP BY, you need SELECT DISTINCT .
Almost all the aggregate functions (like COUNT) have analytic versions.
PARTITION BY is the analytic counterpart to the aggregate GROUP BY. -
Hi,
In SQL, we can create a table from the result of a select statement as follows:
CREATE TABLE table3 AS SELECT * FROM table1, table2 WHERE ...
which is called a "materialized view" because the results of the query are not processed on the fly, but are stored in database table for further processing.
I would like to do something equivalent in Berkeley DB, where the I have some databases that already exist, and I want to perform some processing on them (joins, filters, etc), and instead of getting a cursor, I would like to store the result in a new database (table in SQL terminology). Is there a way to do so? I have Key/Data Java class definitions for the base tables only (table1 and table2 in the SQL example).
Thanks,
Walaa.I understand now, thanks. Now I realize that you're not generating bindings, you have fixed hand-coded bindings for the base table.
The general question you're asking is: How can I store data in BDB without knowing the schema in advance?
Since you are already using Java serialization, this is not too difficult. For the generated database, you could use a TupleSerial binding as you're already doing. This has two parts of course, the key and the data.
I'm not sure what the key should be, perhaps a sequence number? It's up to you.
Because you're using a a TupleSerial binding, the data can be any serialized object. For the serialized data, you could store a List or Map containing the fields that are defined at runtime by the query. A List<Object> may be appropriate if the fields are identified by their order, or a Map<String,Object> if the fields are identified by name. This should work fairly well as long as the List or Map data fields are primitives.
Does this answer your question?
--mark -
MySQL LIMIT clause equivalent in ORACLE statement
Is there an Oracle SQL statement that would be equivalent to the MySQL LIMIT clause used to return only part of a result set?
The preferred solution is to make use of the analytic function ROW_NUMBER. There is a description in the Oracle documentation. The final example shown returns only the fifty-first through one-hundredth row of the EMPLOYEES table:
SELECT last_name FROM
(SELECT last_name, ROW_NUMBER() OVER (ORDER BY last_name) R FROM employees)
WHERE R BETWEEN 51 and 100;An alternative is to use:
select *
from ( select a.*, rownum rnum
from ( YOUR_QUERY_GOES_HERE -- including the order by ) a
where rownum <= MAX_ROWS )
where rnum >= MIN_ROWS;which is discussed on asktom.oracle.com. This works from Oracle 8.1 onwards.
-- cj -
Help needed in writing SQL CASE or DECODE statement
Hi experts,
I need to write a SQL to select order_num, cntry_cde, prod_id and Qty by joining order_num on PROD_ORDER and PROD_ORDER_TXT.
Here is my sample data
PRODORDER_
order_num cntry_cde Prod_id Qty
100 US A1 5
101 US A2 10
102 AU A3 4
103 AU A4 9
104 IN A5 3
PRODORDER_TXT_
order_num cntry_cde Prod_id
100 US A1
101 US A2
102 NZ A3
103 AU A4
104 A5
Here is the requirement,
1) If the cntry_cde in PROD_ORDER is same as cntry_cde in PROD_ORDER_TXT then select PROD_ORDER.cntry_cde (orders 100, 101, 103)
2) If they are different, pick the country code from PROD_ORDER_TXT (order 102, AU <> NZ)
3) If they are different and PROD_ORDER_TXT.cntry_cde is NULL, I cannot use it as cntry_cde in my report (order 104). It happenend just because of the bad data at source.
I cannot avoid it. Then simply use the cntry_cde from PROD_ORDER
Output expected
100 US A1 5
101 US A2 10
102 NZ A3 4 -- AU changed to NZ
103 AU A4 9
104 IN A5 3 -- IN retained as PROD_ORDER_TXT.cntry_cde is null
sample table creation and insert statements are below
create table prod_order
(order_num number,
cntry_cde CHAR(2),
prod_id VARCHAR2(6),
qty number)
create table prod_order_txt
(order_num number,
cntry_cde CHAR(2),
prod_id VARCHAR2(6))
insert into prod_order values (100, 'US', 'A1',5);
insert into prod_order values (101, 'US', 'A2',1);
insert into prod_order values (102, 'AU', 'A3',4);
insert into prod_order values (103, 'AU', 'A4',9);
insert into prod_order values (104, 'IN', 'A5',3);
insert into prod_order_txt values (100,'US','A1');
insert into prod_order_txt values (101,'US','A2');
insert into prod_order_txt values (102,'NZ','A3');
insert into prod_order_txt values (103,'AU','A4');
insert into prod_order_txt values (104,NULL,'A5');
commit;
Thanks for your help in advance
Edited by: sarvan on Mar 28, 2012 1:39 PMHello
Thank you for posting all of the ddl and test data along with your expected output - very helpful!. One small point would be to remember to type {noformat}{noformat} before and after any section of code or data in your post so that formatting is retained. Anyway, this should be a simple join and a combination of CASE and NVL...Select
po.order_num,
CASE
WHEN po.cntry_cde != NVL(pot.cntry_cde,po.cntry_cde)
THEN
pot.cntry_cde
ELSE
po.cntry_cde
END cntry_code,
po.prod_id,
po.qty
FROM
prod_order po
JOIN
prod_order_txt pot
ON
( po.order_num = pot.order_num
ORDER_NUM CN PROD_I QTY
100 US A1 5
101 US A2 1
102 NZ A3 4
103 AU A4 9
104 IN A5 3
5 rows selected.
HTH
David
Edited by: Bravid on Mar 28, 2012 8:32 AM
corrected != -
PL/SQL Function in Select statement
Hi
I am calling a function in select statement. The query works in Toad and PL/SQL developer except SQL plus and disconnecting Oracle connection.
The error is “ERROR at line 1: ORA-03113: end-of-file on communication channel”.
When I called the same query from BC4J View Object the error message is “java.sql.SQLException: No more data to read from socket”.
Can any one advise me please?
Thanks
SriniSrini
I've seen similar cases in the past with 9.2.0.x (x <= 5). What Oracle version are you using? It's worth checking the bug database (I can't just now - I don't have a valid support id in my current contract). And as Warren says, post your SQL query.
HTH
Regards nigel -
PL/SQL equivalent of T-SQL - "group function is not allowed here"
Hi all, hope someone can give me a hand as I'm pretty stuck! I have been trying to convert some MS SQL Server T-SQL statements into Oracle PL/SQL and am stuck on the below one:
SELECT
CA.AssessmentID,
(SELECT ProductName + ISNULL(' - ' + PrincipalBenefit,'')
FROM rptPolicySnapshot WHERE PolicyID = MAX(CA.PolicyID)
AND SnapshotID = 1),
MAX(CA.PolicyID)
FROM rptClaimInvoiceLineSnapshot CIL
INNER JOIN rptClaimAssessmentSnapshot CA
ON CIL.AssessmentID = CA.AssessmentID
AND CIL.SnapshotID = CA.SnapshotID
WHERE CIL.SnapshotID = 1
GROUP BY CA.AssessmentID
This works fine in MSSQL but returns the below error in Oracle:
'ORA-00934: group function is not allowed here'
If I take out the subquery the query works fine.
Any ideas as to the syntax? I am new to Oracle so not sure as to how I should go about writing this.
Thanks in advance!
LeoWITH x AS (SELECT ca.assessmentid,
MAX (ca.policyid) policy_id
FROM rptclaiminvoicelinesnapshot cil
INNER JOIN rptclaimassessmentsnapshot ca
ON cil.assessmentid = ca.assessmentid
AND cil.snapshotid = ca.snapshotid
WHERE cil.snapshotid = 1
GROUP BY ca.assessmentid
SELECT x.assessment_id,
x.policy_id,
productname + decode(principalbenefit,null,null,' - ' || principalbenefit ) prodname
FROM rptpolicysnapshot, x
WHERE policyid = x.policy_id
AND snapshotid = 1I think that's in the neighbourhood.
Maybe you are looking for
-
How to add line items to Accounting Document posted through MIRO ?
I need to perform Additional posting when Posting through MIRO transaction..i tried with INVOICE_UPDATE BADI but this was not useful...Please let me know if there is any way to add additional posting to Accounting Document created through MIRO. If an
-
ORA-01000: maximum open cursors exceeded with Thin and OCI
Hi I have this ERROR : ORA-01000: maximum open cursors exceeded ORA-06510: PL/SQL: unhandled user-defined exception ORA-06512: at line 1 and all the connections show this error, I run the weblogic.Admin RESET_POOL utility and the problem are fixed !!
-
Hi, Trying to add a form for visitors to a site allowing them to sign up for an e-mail newsletter. Can anyone point me to a good tutorial for this task. The dreamweaver side is basic enough but I guess I will have to make stuff happen at the server s
-
SBS2003: disable Exchange Services
We use SBS2003 with Exchange - SMTP for send, POP3 for receive. We want to stop the server from sending & receiving mail while we export user mailboxes/PSTs for the purpose of importing them into Exch 2013. Is the best thing to do, in order to accom
-
OS Upgrade - Can Clustering work on two diff OS levels?
I have WLS7.0sp2 installed on a pair of Solaris 8 boxes. We are upgrading the OS to 9 but the users don't want a down time on their Apps. Therefor, we can't take the whole app down and hit both boxes with the upgrade. My hunch is that if we upgrade o