MS SQL equivalent query
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
Similar Messages
-
PL/SQL spatial query will not compile.
I have a PL/SQL spatial query that will not compile, but the equivalent SQLPlus query works fine. I.e. (convert decimal degrees to degrees,minutes,seconds)
Any thoughts much appreciated....
THIS WORKS in SQLPlus
select
decode(rownum,1,decode(sign(b.column_value),-1,'W','E'),2,decode(sign(b.column_v
alue),-1,'S','N'))| |
to_char(abs(trunc(b.column_value,0)),'999')
| |to_char(abs(trunc((b.column_value - trunc(b.column_value,0)) * 60,0)),'99')
| |to_char(abs(
(((b.column_value - trunc(b.column_value,0)) * 60) - trunc((b.column_value - tru
nc(b.column_value,0)) * 60,0)) * 60
),'99.99')
from route_location a, table(a.line.sdo_ordinates) b
where a.route_adms_id = 13820370
and record_seq_num = 26
and rownum < 3
BUT THIS DOES NOT
ADMS>create or replace procedure PKG_route_loc_latlong_ins
2 (iADMS_ID in INTEGER, iRSN in INTEGER,
3 vcLAT out VARCHAR2, vcLONG out VARCHAR2) as
4 cursor c1 is
5 select decode(rownum,1,decode(sign(b.column_value),-1,'W','E'),
6 2,decode(sign(b.column_value),-1,'S','N'))
7 | |to_char(abs(trunc(b.column_value,0)),'999')
8 | |to_char(abs(trunc((b.column_value - trunc(b.column_value,0)) * 60,0)),
'99')
9 | |to_char(abs(
10 (((b.column_value - trunc(b.column_value,0)) * 60) -
11 trunc((b.column_value - trunc(b.column_value,0)) * 60,0)) * 60
12 ),'99.99')
13 from route_location a, table(a.line.sdo_ordinates) b
14 where a.route_adms_id = iADMS_ID
15 and a.record_seq_num = iRSN
16 and rownum < 3;
17 BEGIN
18 open c1;
19 fetch c1 into vcLONG;
20 fetch c1 into vcLAT;
21
22 EXCEPTION
23 when others then
24 vcLAT := 'ERROR';
25 RAISE_APPLICATION_ERROR(-20002,
26 'XXXXXXXXXXXXXX ');
27
28 END pkg_route_loc_latlong_ins;
29 /
Warning: Procedure created with compilation errors.
ADMS>
ADMS>show errors
Errors for PROCEDURE PKG_ROUTE_LOC_LATLONG_INS:
LINE/COL ERROR
5/5 PL/SQL: SQL Statement ignored
5/12 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
5/12 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
13/34 PLS-00201: identifier 'A.LINE' must be declared
19/5 PL/SQL: SQL Statement ignored
20/5 PL/SQL: SQL Statement ignored
nulltry a
FOR UPDATE OF ID NOWAIT;where ID is the name of a column in the table. -
How to tune the performance of Oracle SQL/XML query?
Hi all,
I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
SELECT XMLElement("CUSTOMER",
XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
(SELECT XMLAgg(XMLElement("ORDERS",
XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
(SELECT XMLAgg(XMLElement("LINEITEM",
XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
FROM LINEITEM
WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
FROM ORDERS
WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
FROM CUSTOMER ;
Thanks very much in advance for your time,
Jinghao Liuajallen wrote:
Why not something more like
SELECT *
FROM fact1 l,
FULL OUTER JOIN fact1 d
ON l.company = d.company
AND l.transactiontypeid = 1
AND d.transactiontypeid = 2;
Because this is not an equivalent of the original query.
drop table t1 cascade constraints purge;
drop table t2 cascade constraints purge;
create table t1 as select rownum t1_id from dual connect by level <= 5;
create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
T1_ID T2_ID
3 3
4 4
5 5
6
7
T1_ID T2_ID
1
2
3 3
4 4
5 5
6
7 -
Converting SQL Server Query to Oracle
Hello TechFriends,
Can any one of u please tell me equivalent of following SQL Server Query?
The same query runs in Oracle but givesa same reocrds in different order!! I want such an equivalent oracle query that gives records in same order as Sql Server does.
select
ProfValue_ProfScaleFK ProfScale,
ProfValue_Value ProfValue,
isnull(ProfValueDesc.name, ProfValue_name) ProfName
from
ProfValueDesc inner join TBL_LMS_Lang
on lang_fk = lang_pk and langid = 'en'
right outer join ProfValue
on ProfValue_ProfScaleFK = ProfScale_fk and ProfValue_Value = ProfValue_FK ;
Regards & TIA.
Anand.If you want a specific ordering why don't you add an ORDER BY clause?
Donal -
Oracle SQL Select query takes long time than expected.
Hi,
I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
The query is as follows.
select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
Kindly advice what is going wrong??
Regards,
PurushothamSQL> @/alcatel/omc1/data/query.sql
2 ;
9 rows selected.
Execution Plan
Plan hash value: 3745571015
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | SORT ORDER BY | |
| 2 | NESTED LOOPS | |
| 3 | NESTED LOOPS | |
| 4 | TABLE ACCESS FULL | PARAMETERTABLE |
|* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
|* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
|* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
|* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
Predicate Information (identified by operation id):
5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
6 - access("P1"."ID"="F1"."ID")
7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
8 - access("F1"."ID"="ID")
Note
- rule based optimizer used (consider using cbo)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
0 bytes sent via SQL*Net to client
0 bytes received via SQL*Net from client
0 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
9 rows processed
SQL> -
hi friends,
i've a view called "risk_efforts" with fields user_id,user_name,wknd_dt,week_day,prod_efforts,unprod_efforts.
Name Type
ROW_ID NUMBER
USER_ID VARCHAR2(14)
USER_NAME VARCHAR2(50)
WKND_DT VARCHAR2(8)
WEEK_DAY VARCHAR2(250)
PROD_EFFORTS NUMBER
UNPROD_EFFORTS NUMBER
data is like this:
when there is some data in prod_efforts, unprod_efforts will be null
when there is some data in unprod_efforts, prod_efforts will be null
for example:
USER_ID USER_NAME WKND_DT WEEK_DAY PROD_EFFORTS UNPROD_EFFORTS
G666999 GTest 20100403 TUE null 3
G666999 GTest 20100403 TUE 14 null
now i want to combine these 2 rows into 1 row i.e o/p should be like this
USER_ID USER_NAME WKND_DT WEEK_DAY PROD_EFFORTS UNPROD_EFFORTS
G666999 GTest 20100403 TUE 14 3
i've tried all combinations but couldn't get the query. Please help me with the exact SQL select query.
thanks,
GirishWelcome to the forum.
First read this:
Urgency in online postings
Secondly, it's always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
You have provided #3 and #4. However with no usable form of sample data forum members will often not respond as quickly as they could if you provided #2.
I'm just wagering a guess here but what about this:SELECT ROW_ID
, USER_ID
, WKND_DT
, WEEK_DAY
, MAX(PROD_EFFORTS) AS PROD_EFFORTS
, MAX(UNPROD_EFFORTS) AS UNPROD_EFFORTS
FROM RISK_EFFORTS
GROUP BY ROW_ID
, USER_ID
, WKND_DT
, WEEK_DAY -
How to capture all the rows returned from a sql select query in CPO
Hi,
I am executing an sql select query which returns multiple rows. I need to capture the values of each row to specific variables. How do I proceed.
Thanks,
SwatiThe select activities ("Select from Oracle," Select from SQL Server," etc.) against database already return tables. Use one of the database adapters to do your select, and it will already be in a table form. Just put your query in the select and identify the columns in your result table. The online help or the database adapter guides in the product documentation can help.
-
Reg: SQL select Query in BPEL process flow
<p>
Hi,
I am suppose to execute a SQL select query (in BPEL Process flow) as mention below in JDeveloper using Database adapter.
</p>
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE ITEM= <xyz>
</p>
<p>
AND OBJECT= (SELECT CASE_NAME FROM CUBE_SUPPLIER WHERE ITEM=<xyz> AND SUPP_IND = ‘Y')
<strong>Now my question is:
1.</strong> What does this "*" refer to in the query and how can I retrieve the value of LENGTH*WIDTH* HEIGHT from the query where LENGTH,WIDTH and HEIGHT are the individual field in the table.
2.What does this " AS" refer to? If " ITEM_CUBE " is the alies for the table name "ITEM" to retrieve the value, then query shoud be evaluated as
</p>
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE <strong>ITEM_CUBE.ITEM</strong>= <xyz>
</p>
<p>
AND <strong>ITEM_CUBE.OBJECT</strong>= (SELECT CASE_NAME FROM CUBE_SUPPLIER WHERE ITEM=<xyz> AND SUPP_IND = ‘Y')
Is my assumption correct?
Please suggest asap.
Thanks...
</p>
<p>
</p>Hi
Thank for your reply!
I have a nested select query which performs on two different table as shown below:
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE ITEM= <abc>
</p>
<p>
AND OBJECT= (SELECT NAME FROM SUPPLIER WHERE ITEM=<Item> AND SUPP_IND = ‘Y')
I am using DB adapter of Oracle JDeveloper in BPEL process flow, where I can able to select only one master table in DB adapter say SUPPLIER and its attributes at a time.But as per my requirment I need to select both the table (CUBE and SUPPLIER) in a single adapter to execute my query.
It can be achievable by using two DB adapter , One to execute the nested query and another to execute the main qyery considering value of nested query as a parameter.But I want to achieve it by using a single one.
Am I correct with my concept?
Please suggest how to get it ?
</p>
Edited by: user10259700 on Oct 23, 2008 12:17 AM -
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... -
I want to get all the documents based on content type using SQL Server Query. I know that, querying the content database without using API is not advisable, but still i want to perform this action through SQL Server Query. Can someone assist ?
You're right, it's not advisable, may result in corruption of your databases and might impact performance and stability. But assuming you're happy to do that then it is possible.
Before you go down that route, have you considered using something more safe like PowerShell? I've seen a script exactly like the one you describe and it would take far less time to do it through PS than it would through SQL. -
sql server query to rearrange the rows after inserting the rows in a table
You want to re-arrange the data physically?!!! Why? I believe its something impossible other than having a clustered key(there could be some strange ways of doing it) and a thing that should not worry about. Always there is a ORDER BY CLAUSE to order your
data while retrieving
Satheesh
My Blog |
How to ask questions in technical forum -
Sql developer query window corrupting on scroll
Hi there
I have a weird error - when I scroll in my SQL developer query window (tab) the text corrupts and only comes back if I click in the window somewhere or save. Has anyone else seen this? I'm on version 1.5.5 and don't really want to upgrade to the latest as I don't like the new layout (no dbmsoutput etc in the results window)
Cheers, Katesorted it by adding a line AddVMOption -Dsun.java2d.noddraw=true to the sqldeveloper.conf file, as per thread SQL Editor not refreshing after scroll on Windows Vista
-
How to perf tune Oracle SQL/XML query?
Hi all,
I am using Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
SELECT XMLElement("CUSTOMER",
XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
(SELECT XMLAgg(XMLElement("ORDERS",
XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
(SELECT XMLAgg(XMLElement("LINEITEM",
XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
FROM LINEITEM
WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
FROM ORDERS
WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
FROM CUSTOMER ;
Thanks very much in advance for your time,
Jinghao LiuPlease post this message at:
Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB -
Using SQL in Query in 3.0.0
I'm very happy to see this feature added to 3.0.0 along with methodQL. This
should alleviate a lot of the issues with trying to use only JDOQL,
especially when the desired SQL statemetn is well understood. Thanks for
adding this!
BenMarc,
Calling pm.flush() explicitly doesn't help. Calling
query.setIgnoreCache(true) does work, so that's good.
I even get the correct number of rows back in the Collection. Unfortunately
every item in the Collection is null. I definitely did a
query.setClass(DSChannelValueImpl.class) and it is enhanced properly,
because that's how the table got populated earlier in the test. I am doing a
SELECT *, so the class indicator and pk should be there. I'm assuming it
doesn't mind me aliasing the FROM table name, since I need to disambiguate
it to do a join (below).
Ben
"Marc Prud'hommeaux" <[email protected]> wrote in message
news:[email protected]...
Ben-
I've made a bug report for this:
http://bugzilla.solarmetric.com/show_bug.cgi?id=780
In the meantime, a nicer workaround will probably be to just call
setIgnoreCache(true) on the Query.
In article <[email protected]>, Marc Prud'hommeaux wrote:
Ben-
A potential (but, admittedly, not very nice) workaround for this for the
time being might be to enable NonTransactionalRead=true, and ensure that
there is not a transaction running at the time of query execution.
In article <[email protected]>, Patrick Linskey wrote:
Well, sounds like a bug. We'll take a look. Sorry about that.
What happens if you explicitly flush the PM before execution?
-Patrick
Ben Eng wrote:
Query query = pm.newQuery( "kodo.jdbc.SQL", null );
query.setClass( ChannelValue.class );
query.declareParameters( "VARCHAR pConn, DATETIME pStart,
DATETIME pEnd" );
String filter = "select * from dschannel as c" +
" left join channelsegment as s" +
" on c.pk = s.channel and" +
" c.supporting = pConn and" +
" (s.validForEnd > pStart or" +
" s.validForStart < pEnd)" +
" where s.channel is null";
query.setFilter( filter );
Collection resultSet = (Collection) this.query.execute(
connection, start, end );
This is being called from a method of a stateless session bean that is
only
performing this query. CMT, Required, and the client is not definingits own
transaction boundaries. Therefore, I would not expect anything to bedirtied
in this transaction. This is with the BEA WLS 7.0 appserver.
Ben
"Patrick Linskey" <[email protected]> wrote in message
news:[email protected]...
Ben,
Can you post the code that you're using to create the query?
-Patrick
Ben Eng wrote:
I just ran into a snag with this feature.
kodo.util.UnsupportedOptionException: kodo.jdbc.SQL language queries
cannot
be executed in-memory. Either set the javax.jdo.option.IgnoreCacheproperty
to true, set the kodo.FlushBeforeQueries property to true, or executethe
query before modifying objects within the transaction.
at
kodo.jdbc.query.SQLQuery.newInMemoryQueryExecutor(SQLQuery.java:117)
at kodo.query.AbstractQuery.internalCompile(AbstractQuery.java:545)
atkodo.query.AbstractQuery.getAccessPathMetaDatas(AbstractQuery.java:938)
>>>>
atkodo.query.AbstractQuery.isAccessPathDirty(AbstractQuery.java:745)
at kodo.query.AbstractQuery.executeWithMap(AbstractQuery.java:672)
at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:640)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:622)
at
com.metasolv.resources.queries.ChannelAvailabilityQueryBean.execute(ChannelA
>>>>
vailabilityQueryBean.java:84)
at
com.metasolv.oss.inventory.InventorySessionBean.queryInventory(InventorySess
>>>>
ionBean.java:1504)
Oddly, my ra.xml already has the following properties set.
<config-property>
<description>If false, then the JDO implementation mustconsider
modifications, deletions, and additions in the PersistenceManager
transaction cache when executing a query inside a transaction. Else,the
implementation is free to ignore the cache and execute the querydirectly
against the data store.</description>
<config-property-name>IgnoreCache</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
<config-property>
<description>Whether or not Kodo should automatically flush
modifications to the data store before executingqueries.</description>
>>>>>>
<config-property-name>FlushBeforeQueries</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
I also tried explicitly calling ((KodoPersistenceManager)pm).flush()before
newQuery to no avail. I am at a loss how to get the Query to NOT
execute
in-memory.
Ben
"Ben Eng" <[email protected]> wrote in message
news:[email protected]...
I'm very happy to see this feature added to 3.0.0 along with
methodQL.
>>>>>>
This
should alleviate a lot of the issues with trying to use only JDOQL,
especially when the desired SQL statemetn is well understood. Thanks
for
adding this!--
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
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?
ThanksHow 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.
Maybe you are looking for
-
Ok I bought it installed it used online chat and then they called. I cant understand what they are saying on the phone I speak English. Have bad hearing and just couldnt understand half the words so here we go.I have a linksys wmp54g - wre54g live in
-
Oracle 8.0.5 & SUSE Linux 6.0
I am attempting to install Oracle 8.0.5 on SuSE 6.0 Linux but receive the following error messages: When running oratabs.sh - "GROUPS: read only variable" When running orainst - "Permission Denied" I have no patches installed on SuSE - do I need any?
-
Unable to upload book order in iPhoto 08 w/Leopard
My situation is similar to others I have seen on these boards, but since none of the possible solutions mentioned have worked for me, I thought I would post my problem and see if anyone can help. I have a MacBook running Leopard 10.5.1 with iPhoto 7.
-
Servlets, JDBC, and Arabic
when using the Java Servlets to process an HTML Form that have Arabic input .. the Arabic input is not viewable in any proper encoding after INSERTing it to a Access DB using the JdbcOdbc bridge .. How can I make sure of the encoding before INSERTing
-
Recommended SCSI to SATA converter for older external hard drive enclosure?
I have a SCI external hard drive enclosure that I would like to be able to use a with a SATA drive. Can anyone suggest an inexpensive, reliable SCSI to SATA bridge board?