SQL query needed to identify cancelled invoice where distribution lines
SQL query needed to identify cancelled invoice where distribution lines Debit is not equal Credit line item in particular
Is there a way from back end FROM ap_invoice_distributions_all where we can find for the cancelled invoice where distribution lines Debit is not equal Credit line item
Regards,
Prakash Ranjan
Hello Prakash
Can you please see if this query helps you?
SELECT i.invoice_id, i.invoice_amount, nvl(sum(d.amount),0)
FROM ap_invoice_distributions_all d, ap_invoices_all i
WHERE i.org_id = <you org_id>
AND i.invoice_id = d.invoice_id
AND d.line_type_lookup_code not in ('PREPAY')
AND i.cancelled_date IS NOT NULL
GROUP BY i.invoice_id, i.invoice_amount
HAVING (i.invoice_amount <> nvl(sum(d.amount),0))
ORDER BY i.invoice_id asc
Octavio
Similar Messages
-
Hi All,
I have belwo two record values.
select 1 as seq_no,'test1' as data_set from dual
union
select 1,'12test' from dual
union
select 2,'abcd' from dual
union
select 2,'ilm' from dual
union
select 2,'12test444' from dual
here i need to extract the below o/p from from the above dataset
1,12test
1,test1
2,12test444
select 1 as seq_no,'test1' as data_set from dual
union
select 1,'12test' from dual
union
select 2,'abcd' from dual
union
select 2,'ilm' from dual
here i need to extract the below o/p from from the above dataset
1,12test
1,test1
2,abcd
2,ilm
The logic behind the above two types of o/p is
if the search string 'test' is present in any data set (data set is defined by same seq_no values) then print the whole row containing the search string. As in the first record value data set with seq_val 1 and 2 both have test string 'test' , o/p is all the rows contating the search string 'test'
If the search string 'test' is not present in any data set (data set is defined by same seq_no values) then print all other rows not containing the search string. As in the second record value data set with seq_val 2 both doesn't have test string 'test' , o/p is all the rows not contating the search string 'test' in data test with seq_val 1as well as all the rows contating the search string 'test' in data set with seq_val 2
Hope i could explain my o/p logic and i need to perform this in a sql query.
Waiting for your responses.
Thanks in advance.Hi,
Here's one way:
WITH got_rnk AS
SELECT seq_no, data_set
, DENSE_RANK () OVER ( PARTITION BY seq_no
ORDER BY CASE
WHEN INSTR (data_set, 'test') > 0
THEN 1
ELSE 2
END
) AS rnk
FROM table_x
SELECT seq_no, data_set
FROM got_rnk
WHERE rnk = 1
;The CASE expression returns 1 if data_set contains 'test', and it returns 2 if it does not. Let's call this number x.
You're not really interested in x itself. Rather, you want all the rows that have the lowest value of x among rows with the same seq_no. That is, if any row with a given_seq_num has x=1, then you want all rows with that seq_no and x=1, but it the lowest x for the a seq_no is 2, then you want the rows with x=2 instead.
DENSE_RANK returns the the number 1 if the given riow is the lowest (or tied for the lowest) in its partition, so if the are any rows with x=1 in the group, rnk=1 will correspond to x=1. But if all the rows with the same seq_no have x=2, then rnk=1 will correspond to x=2. -
Simplify SQL query - need suggestions
Hi,
I have a table "Product" in my Database , which i am using to create reports in OBIEE. The table has five cols : ID, Version, Date, ItemName, ItemRate . It is partitioned on Date col . The table has many rows and I want to hit Date partition to improve performance.I take Date as input from user by Date Prompt.
The primary key is ID+Version+ItemName
I want to get a table which contains Date, ItemName,ItemRate, ID for each ID with max(Version). This table I will join with another table in Oracle BI Answers to generate reports. If an ID has many versions, I get max version value and then return ID,ItemName,ItemRate,Date corresponding to that Verion value.
What is the best way to achieve this, should I define view in my physical layer which contains sql query for simplified table so that it will make my task of generating reports easier by having asimplified table in Oracle BI Answers ? ?
Please ask if any clarification is needed ....
ThanksThere are couple of ways to handle your requirements. Try this:
When table is partitioned we have to use fragmentation option using LTS->Proparties->Content tab specify the condition at
Fragmentation content:
and
Check 'This source should...'
For Max(version): Use repository variable for getting max(version) and filter using Where clause option in Content tab.
Let me know updates -
Sql Query need to extract the Work Flow information from Hyperion Planning
Can Any one give me the sql query to extract the Work flow from Hyperion Planning in 11.1.2.1.
I can extract from the Hyperion Planning but it is not in required format again I need to do lot of formating. I need the information as per the flow structure is showing linke in one perticular planning unit in all coloumn format. Hence only sql query will help me to extract this kind of information. could any one provide the sql query to extract this kind of request.
Thanks in Advance.
Edited by: 987185 on Feb 9, 2013 10:57 PMIf you have a look at the data models in - http://www.oracle.com/technetwork/middleware/bi-foundation/epm-data-models-11121-354684.zip
There is the structure of the planning application tables, have a look at the HSP_PM_* tables
Alternatively you can look at extracting the information using LCM.
Cheers
John
http://john-goodwin.blogspot.com/ -
Sql query need for date format''Mon 23 Apr 16:45 pm'
i need SQL query to print date like 'Mon 23 Apr 16:45 pm' format
SQL> select to_char(sysdate,'Dy fmddfm Mon hh24:mi pm','nls_date_language=american') from dual
2 /
TO_CHAR(SYSDATE,'DY
Fri 27 Apr 13:04 pm
1 rij is geselecteerd.Regards,
Rob. -
List the count of each schema objects.. schema wise sql query needed
Hi Friends,
i need a sql query which has to list the schema name along with the count of schema objects like tables,views,triggers.... order by schemaname
Regards,
DBHi
You can try this option if you use 11g .
Get all the object types in your db.
SELECT DISTINCT object_type
FROM dba_objects;Then include all the object types in to the below query.
select *
from (select owner, object_type, 1 CNT
from dba_objects ) e
pivot( sum(CNT) for object_type in
( 'INDEX','TYPE','VIEW','LIBRARY','TRIGGER','DIRECTORY','PACKAGE','QUEUE','PACKAGE BODY','TABLE PARTITION','PROCEDURE',
'WINDOW','CLUSTER','LOB','FUNCTION','CONSUMER GROUP','CONTEXT','RULE','XML SCHEMA','SEQUENCE','INDEX PARTITION','OPERATOR',
'EVALUATION CONTEXT','SCHEDULE','JOB','SCHEDULER GROUP','LOB PARTITION','JOB CLASS','INDEXTYPE','TABLE','TYPE BODY','RESOURCE PLAN',
'TABLE SUBPARTITION','UNDEFINED','DESTINATION','SYNONYM','EDITION','PROGRAM','RULE SET' ) )
order by owner;Cheers
Kanchana -
Sql query needed to verify force logging
Hi.
Does anyone out there have SQL query we need to run in order to see if our db is working in force logging mode?
Thanks.
DAThe FORCE_LOGGING column of v$database view can be queried to verify that the database is in FORCE LOGGING mode. Similarly, the FORCE_LOGGING column of dba_tablespace view provides the same information for each tablespace.
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Hi All,
We have a native SQL query accessing Oracle database(given below).
Can anyone please let me know what this query is about and how can we fine tune the query?
SELECT O.OBJECT_NAME ,
H.SID,
HS.MACHINE,
HS.PROCESS,
W.SID,
WS.MACHINE,
WS.PROCESS,
H.CTIME,
W.CTIME,
WS.ROW_WAIT_OBJ#,
WS.ROW_WAIT_FILE#,
WS.ROW_WAIT_BLOCK#,
WS.ROW_WAIT_ROW#,
HP.SPID,
WP.SPID
FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,
V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP
WHERE H.ID1 = W.ID1
AND H.SID <> W.SID
AND H.TYPE IN ('TX','DL')
AND H.REQUEST = 0
AND H.SID = I.SID
AND I.TYPE = 'TM'
AND I.ID1 = O.OBJECT_ID
AND I.ID1 = I2.ID1
AND W.SID = I2.SID
AND I2.TYPE = 'TM'
AND H.SID = HS.SID
AND W.SID = WS.SID
AND HS.PADDR = HP.ADDR
AND WS.PADDR = WP.ADDR
INTO :EXCL_LOCK_WAITERS-OBJ_NAME ,
:EXCL_LOCK_WAITERS-HOLDER_SID ,
:EXCL_LOCK_WAITERS-H_HOSTNAME ,
:EXCL_LOCK_WAITERS-HOLDER_PID ,
:HOLDER_PID ,
:EXCL_LOCK_WAITERS-WAITER_SID ,
:EXCL_LOCK_WAITERS-W_HOSTNAME ,
:EXCL_LOCK_WAITERS-WAITER_PID ,
:WAITER_PID ,
:EXCL_LOCK_WAITERS-HELD_SINCE ,
:EXCL_LOCK_WAITERS-WAITSSINCE,
:ROW_WAIT_OBJ,
:ROW_WAIT_FILE,
:ROW_WAIT_BLOCK,
:ROW_WAIT_ROW,
:H_PROCESS,
:W_PROCESS
ENDEXEC
Thanks in advance.
Neethu MohanHi Neethu,
It gives you an overwiew of blocking Oracle sessions.
1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX) to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX') => holders
It joins these with the sessions that are waiting of releasing the lock by the holders => waiters.
2. it retrieves the detail information wich Oracle process , the object (table) , it's row , block and file
are affected by the locks.
3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.
4. Tuning
V$tables are expensive to query: Why?
v$ tables are generally Oracle memory structures.
v$ tables are not read consistent.
v$ tables require latches to access -- cannot modify and read memory at the same
time.
heavy access to v$ tables like this may cause some serious heavy duty contention.
Especially if you self join V$lock several times.
So the best would be to save the contents of V$LOCK in some table:
Create table mylocks as select * from v$lock;
Use that table for self-joining and joins to the other tables.
You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving
v$ directly.
You can empty or drop the created tables any time for new data.
Because you want to investigate only lock hold for a longert time to copy the v$ memory structures into
physical tables is not a disadvantage. You certainly will wait longer on finishing your query
instead of copy them into the tables.
Hope this helped
yk -
SQL Query if or case omit fields but not line.
I have the below SQL Query my goal is to not show Aging or Storage Date if QTY is greater than 0.
I know I can omit the line but I still want to show just not those two fields is this possible?
Select sl.SKU, sl.LOC, (editdate) AS "Storage Date", CAST(sysdate-editdate AS DECIMAL(10,2)) AS Aging, sl.QTY, sl.QTYALLOCATED
From skuxloc sl
Where sl.SKU in ('315A6112-29','315A6112-33')
This is what I'm looking for:
Work Smarter Not HarderAre you working with OracleSQL, There is no sysdate in SQL Server.
Select sl.SKU, sl.LOC,
case when sl.QTY =0 then '' else editdate end AS 'Storage Date',
case when sl.QTY =0 then '' else CAST(sysdate-editdate AS DECIMAL(10,2)) END
AS Aging,
sl.QTY, sl.QTYALLOCATED
From skuxloc sl
Where sl.SKU in ('315A6112-29','315A6112-33')
If you are working with Oracle, You can try decode.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions040.htm
http://www.dba-oracle.com/t_decode_function.htm
--Prashanth -
Guys,
I am struggling with this sql. Any better ways of writing this one ?
SELECT entity_id, SUM (volume)
FROM (SELECT ev.entity_id, NVL (SUM (ev.volume), 0) AS volume
FROM entity_volume ev
WHERE ev.entity_id IN
(112764,
112800,
112878,
112916,
112974,
113016,
113061,
113102,
113130,
113177,
113224,
113259,
113287,
113319,
113361,
113430,
113465,
113493,
113536,
113584,
113620,
113648,
113691,
113740,
113808,
113838,
113878,
113949,
113986,
114014,
114057,
114103,
114141,
114169,
114211,
114260,
114299,
114328,
114865,
114883,
114903,
114935,
114955,
114975,
115031,
115045,
115062,
115079,
115101,
115139,
115156,
115172,
115192,
115212,
115232,
115272,
115286,
115300,
115317,
115339,
115360,
115399,
115434,
115451,
115469,
115483,
115521,
116520,
116660,
122648,
122676,
122704,
122732,
122760,
123045,
123101,
123157,
123213,
123269,
126138,
129461,
129476,
129477,
129479,
129480,
129481,
129483,
129484,
129485,
130025,
130028,
130042,
139650,
139672,
139694,
139716,
139739,
139761,
139784,
139806,
139829,
139851,
139896,
139918,
140120,
140142,
140160,
140178,
140196,
140212,
140461,
141098,
141114,
141130,
141173,
141377,
143040,
143073,
143106,
143139,
143172,
143205,
143240,
143273,
143306,
143339,
143372,
143405,
143440,
143473,
143506,
143539,
143572,
143605,
150444,
150447,
146425,
150460,
146656,
146657,
146658,
146659,
146660,
146661,
146662,
146664,
146666,
146668,
146669,
146670,
146671,
146672,
146673,
146674,
146675,
146676,
146677,
146678,
146679,
150472,
150483,
149824,
149823,
149821,
149865,
149934,
149869,
149868,
149935,
148233,
149936,
148266,
148299,
149076,
148332,
148366,
148399,
148498,
148531,
148564,
148597,
149109,
148663,
148696,
148795,
148828,
148861,
148894,
148928,
148961,
149176,
149209,
149276,
149309,
149373,
149427,
149460,
149493,
149527,
149560,
149593,
149627,
149660,
149693,
151010,
151043,
150942,
150977,
151078,
151111,
151144,
151178,
151211,
151244,
151281,
151290,
151299,
151391,
151424,
151457,
151491,
151524,
151557,
151591,
151624,
151657,
151689,
151695,
151705,
151711,
151713,
151750,
151798,
151799,
151800,
152039,
152040,
152041,
166039,
188961,
196776,
1000324590,
1000324347,
1000323287,
1000323307,
1000323175,
1000323197,
1000323220,
1000323242,
1000323264,
1000323051,
1000323074,
1000323091,
1000323108,
1000323130,
1000322958,
1000322981,
1000323024,
1000322840,
1000322863,
1000322890,
1000322912,
1000322935,
1000322710,
1000322763,
1000322778,
1000322799,
1000322821,
1000322600,
1000322508,
1000322531,
1000322554,
1000322577,
1000322393,
1000322416,
1000322439,
1000322462,
1000322485,
1000322289,
1000322305,
1000322348,
1000322146,
1000322168,
1000322217,
1000322241,
1000322263,
1000322007,
1000322030,
1000322053,
1000322083,
1000321912,
1000321918,
1000321934,
1000321941,
1000321960,
1000321984,
1000321814,
1000321860,
1000321698,
1000321721,
1000321744,
1000321773,
1000321789,
1000321584,
1000321606,
1000321629,
1000321675,
1000321476,
1000321541,
1000321561,
1000321385,
1000321405,
1000321427,
1000321454,
1000321270,
1000321293,
1000321316,
1000321339,
1000321363,
1000321184,
1000321201,
1000321225,
1000321247,
1000321068,
1000321091,
1000321113,
1000321135,
1000321156,
1000320797,
1000320816,
1000320843,
1000320469,
1000320491,
1000316052,
1000316068,
1000316070,
1000316085,
1000315946,
1000315967,
1000315988,
1000316010,
1000316031,
1000315847,
1000315869,
1000315890,
1000315912,
1000315927,
1000315929,
1000315931,
1000315751,
1000315773,
1000315788,
1000315805,
1000315826,
1000315641,
1000315664,
1000315687,
1000315708,
1000315730,
1000315617,
1000310823,
1000310845,
1000310869,
1000310891,
1000310915,
1000310734,
1000310755,
1000310778,
1000310802,
1000310367,
1000310337,
1000310106,
1000310127,
1000310172,
1000310003,
1000293084,
1000293087,
1000337019,
1000336998,
1000337040,
1000336351,
1000336182,
1000336222,
1000336208,
1000336233,
1000336234,
1000267169,
1000267173,
1000267177,
1000267181,
1000267185,
1000267189,
1000336075,
1000336079,
1000266375,
1000336098,
1000336115,
1000266247,
1000266311,
1000266059,
1000266123,
1000265995,
1000265739,
1000265803,
1000265675,
1000265611,
1000265356,
1000265240,
1000265112,
1000265176,
1000264905,
1000335383,
1000335385,
1000334418,
1000334419,
1000334420,
1000099932,
1000101089,
1000101467,
1000101875,
1000102304,
1000104426,
1000104850,
1000233832,
1000233896,
1000233772,
1000233117,
1000233186,
1000233052,
1000232865,
1000232868,
1000232871,
1000232862,
1000232783,
1000232786,
1000232790,
1000232793,
1000232796,
1000232799,
1000232802,
1000232805,
1000232808,
1000232811,
1000232831,
1000232834,
1000232837,
1000232840,
1000232843,
1000232846,
1000232849,
1000232852,
1000232856,
1000232859,
1000127079,
1000127499,
1000127919,
1000128339,
1000128741,
1000129221,
1000129641,
1000130040,
1000130775,
1000131195,
1000131594,
1000132014,
1000132434,
1000132854,
1000133274,
1000133694,
1000134114,
1000134534,
1000134954,
1000135374,
1000135794,
1000136214,
1000136634,
1000137054,
1000137474,
1000137894,
1000138314,
1000138734,
1000139154,
1000139574,
1000139994,
1000140414,
1000140834,
1000141254,
1000141674,
1000142094,
1000142514,
1000142934,
1000143354,
1000143774,
1000144194,
1000144614,
1000145034,
1000145454,
1000145874,
1000146294,
1000146714,
1000147134,
1000149131,
1000149511,
1000149891,
1000150271,
1000150651,
1000151031,
1000152171,
1000152551,
1000152931,
1000153311,
1000153691,
1000154071,
1000154451,
1000155211,
1000155591,
1000155971,
1000156351,
1000156731,
1000157111,
1000157491,
1000157871,
1000158251,
1000158631,
1000159011,
1000159391,
1000159771,
1000160151,
1000160531,
1000160911,
1000161291,
1000161671,
1000162051,
1000162431,
1000162811,
1000163191,
1000163571,
1000163951,
1000164331,
1000164711,
1000165091,
1000165471,
1000165851,
1000166231,
1000148751,
1000170854,
1000151791,
1000172181,
1000154831,
1000177783,
1000178581
AND ev.period_id IN (
SELECT period_id
FROM period
WHERE month_year < (SELECT start_date
FROM entity_effectivity
WHERE entity_id = ev.entity_id)
OR month_year > (SELECT end_date
FROM entity_effectivity
WHERE entity_id = ev.entity_id))
AND ev.volume_type = 'FC'
AND ev.program_id = :1
GROUP BY ev.entity_id)
GROUP BY entity_id
HAVING SUM (volume) > 0
I am on 9.2.0.2 and explain plan is as below..
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=ALL_ROWS 1 147
FILTER
SORT GROUP BY 1 20 147
VIEW 13 260 143
SORT GROUP BY 13 494 143
FILTER
HASH JOIN 13 494 139
PARTITION RANGE SINGLE KEY KEY
INLIST ITERATOR
TABLE ACCESS BY LOCAL INDEX ROWID ENTITY_VOLUME 137 3 K 136 KEY KEY
INDEX RANGE SCAN ENTITY_VOLUME_IDX_001 137 30 KEY KEY
TABLE ACCESS FULL PERIOD 318 4 K 2
TABLE ACCESS FULL ENTITY_EFFECTIVITY 1 15 33
TABLE ACCESS FULL ENTITY_EFFECTIVITY 1 15 33Guys,
Thanks mate.. I tried all your suggestion and tried with many hints etc.. But the query doesn't seem to come back in less than 30 seconds. Business wants this one to return in 20 seconds where in it's currently taking 1:20 sec
Any one there who could give me a better solution ? Let me know if you need anymore information on this :
SELECT entity_id, SUM (volume)
FROM (SELECT ev.entity_id, NVL (SUM (ev.volume), 0) AS volume
FROM entity_volume ev, period p, entity_effectivity ee
WHERE exists( select 'x' from entity_volume e where e.entity_id = ev.entity_id and entity_id in
(112764,
112800,
112878,
112916,
112974,
113016,
113061,
113102,
113130,
113177,
113224,
113259,
113287,
113319,
113361,
113430,
113465,
113493,
113536,
113584,
113620,
113648,
113691,
113740,
113808,
113838,
113878,
113949,
113986,
114014,
114057,
114103,
114141,
114169,
114211,
114260,
114299,
114328,
114865,
114883,
114903,
114935,
114955,
114975,
115031,
115045,
115062,
115079,
115101,
115139,
115156,
115172,
115192,
115212,
115232,
115272,
115286,
115300,
115317,
115339,
115360,
115399,
115434,
115451,
115469,
115483,
115521,
116520,
116660,
122648,
122676,
122704,
122732,
122760,
123045,
123101,
123157,
123213,
123269,
126138,
129461,
129476,
129477,
129479,
129480,
129481,
129483,
129484,
129485,
130025,
130028,
130042,
139650,
139672,
139694,
139716,
139739,
139761,
139784,
139806,
139829,
139851,
139896,
139918,
140120,
140142,
140160,
140178,
140196,
140212,
140461,
141098,
141114,
141130,
141173,
141377,
143040,
143073,
143106,
143139,
143172,
143205,
143240,
143273,
143306,
143339,
143372,
143405,
143440,
143473,
143506,
143539,
143572,
143605,
150444,
150447,
146425,
150460,
146656,
146657,
146658,
146659,
146660,
146661,
146662,
146664,
146666,
146668,
146669,
146670,
146671,
146672,
146673,
146674,
146675,
146676,
146677,
146678,
146679,
150472,
150483,
149824,
149823,
149821,
149865,
149934,
149869,
149868,
149935,
148233,
149936,
148266,
148299,
149076,
148332,
148366,
148399,
148498,
148531,
148564,
148597,
149109,
148663,
148696,
148795,
148828,
148861,
148894,
148928,
148961,
149176,
149209,
149276,
149309,
149373,
149427,
149460,
149493,
149527,
149560,
149593,
149627,
149660,
149693,
151010,
151043,
150942,
150977,
151078,
151111,
151144,
151178,
151211,
151244,
151281,
151290,
151299,
151391,
151424,
151457,
151491,
151524,
151557,
151591,
151624,
151657,
151689,
151695,
151705,
151711,
151713,
151750,
151798,
151799,
151800,
152039,
152040,
152041,
166039,
188961,
196776,
1000324590,
1000324347,
1000323287,
1000323307,
1000323175,
1000323197,
1000323220,
1000323242,
1000323264,
1000323051,
1000323074,
1000323091,
1000323108,
1000323130,
1000322958,
1000322981,
1000323024,
1000322840,
1000322863,
1000322890,
1000322912,
1000322935,
1000322710,
1000322763,
1000322778,
1000322799,
1000322821,
1000322600,
1000322508,
1000322531,
1000322554,
1000322577,
1000322393,
1000322416,
1000322439,
1000322462,
1000322485,
1000322289,
1000322305,
1000322348,
1000322146,
1000322168,
1000322217,
1000322241,
1000322263,
1000322007,
1000322030,
1000322053,
1000322083,
1000321912,
1000321918,
1000321934,
1000321941,
1000321960,
1000321984,
1000321814,
1000321860,
1000321698,
1000321721,
1000321744,
1000321773,
1000321789,
1000321584,
1000321606,
1000321629,
1000321675,
1000321476,
1000321541,
1000321561,
1000321385,
1000321405,
1000321427,
1000321454,
1000321270,
1000321293,
1000321316,
1000321339,
1000321363,
1000321184,
1000321201,
1000321225,
1000321247,
1000321068,
1000321091,
1000321113,
1000321135,
1000321156,
1000320797,
1000320816,
1000320843,
1000320469,
1000320491,
1000316052,
1000316068,
1000316070,
1000316085,
1000315946,
1000315967,
1000315988,
1000316010,
1000316031,
1000315847,
1000315869,
1000315890,
1000315912,
1000315927,
1000315929,
1000315931,
1000315751,
1000315773,
1000315788,
1000315805,
1000315826,
1000315641,
1000315664,
1000315687,
1000315708,
1000315730,
1000315617,
1000310823,
1000310845,
1000310869,
1000310891,
1000310915,
1000310734,
1000310755,
1000310778,
1000310802,
1000310367,
1000310337,
1000310106,
1000310127,
1000310172,
1000310003,
1000293084,
1000293087,
1000337019,
1000336998,
1000337040,
1000336351,
1000336182,
1000336222,
1000336208,
1000336233,
1000336234,
1000267169,
1000267173,
1000267177,
1000267181,
1000267185,
1000267189,
1000336075,
1000336079,
1000266375,
1000336098,
1000336115,
1000266247,
1000266311,
1000266059,
1000266123,
1000265995,
1000265739,
1000265803,
1000265675,
1000265611,
1000265356,
1000265240,
1000265112,
1000265176,
1000264905,
1000335383,
1000335385,
1000334418,
1000334419,
1000334420,
1000099932,
1000101089,
1000101467,
1000101875,
1000102304,
1000104426,
1000104850,
1000233832,
1000233896,
1000233772,
1000233117,
1000233186,
1000233052,
1000232865,
1000232868,
1000232871,
1000232862,
1000232783,
1000232786,
1000232790,
1000232793,
1000232796,
1000232799,
1000232802,
1000232805,
1000232808,
1000232811,
1000232831,
1000232834,
1000232837,
1000232840,
1000232843,
1000232846,
1000232849,
1000232852,
1000232856,
1000232859,
1000127079,
1000127499,
1000127919,
1000128339,
1000128741,
1000129221,
1000129641,
1000130040,
1000130775,
1000131195,
1000131594,
1000132014,
1000132434,
1000132854,
1000133274,
1000133694,
1000134114,
1000134534,
1000134954,
1000135374,
1000135794,
1000136214,
1000136634,
1000137054,
1000137474,
1000137894,
1000138314,
1000138734,
1000139154,
1000139574,
1000139994,
1000140414,
1000140834,
1000141254,
1000141674,
1000142094,
1000142514,
1000142934,
1000143354,
1000143774,
1000144194,
1000144614,
1000145034,
1000145454,
1000145874,
1000146294,
1000146714,
1000147134,
1000149131,
1000149511,
1000149891,
1000150271,
1000150651,
1000151031,
1000152171,
1000152551,
1000152931,
1000153311,
1000153691,
1000154071,
1000154451,
1000155211,
1000155591,
1000155971,
1000156351,
1000156731,
1000157111,
1000157491,
1000157871,
1000158251,
1000158631,
1000159011,
1000159391,
1000159771,
1000160151,
1000160531,
1000160911,
1000161291,
1000161671,
1000162051,
1000162431,
1000162811,
1000163191,
1000163571,
1000163951,
1000164331,
1000164711,
1000165091,
1000165471,
1000165851,
1000166231,
1000148751,
1000170854,
1000151791,
1000172181,
1000154831,
1000177783,
1000178581 ))
AND ev.period_id = p.period_id
AND ev.entity_id = ee.entity_id
AND (p.month_year < ee.start_date or p.month_year > ee.end_date)
AND ev.volume_type = 'FC'
AND ev.program_id = 1000000462
GROUP BY ev.entity_id)
GROUP BY entity_id
HAVING SUM (volume) > 0 -
Approval Query needed for AR Reserve Invoice
Need to create an approval for delivery doc- If AR reserve invoice not paid need to triger an approval. how can I cutomise the query to look at base document.
SELECT DISTINCT 'TRUE' FROM OINV T0 WHERE T0.[isIns] = 'Y' AND T0.[DocStatus] <> 'C'
Thanks and RegardsHi Anoop,
This one should do it I believe. I have attachde the query as not everything gets copied in this forum. The query below will not work.
SELECT distinct 'true' FROM DLN1 T0 WHERE T0.[BaseType] = 13 and $[$38.45.1] in (SELECT docentry FROM OINV T0 WHERE isins = 'Y' and paidtodate <> doctotal)
There are a few limitations with approvals in B1 that are based on values on the linelevel like this one.
The query can not see past the first line of the document. So it will only check the basedoc of the first item in the Delivery (it is possible to add an item on the first line after copying the Reserve Invoice details into the delivery).
Apart from that, the query only checks if the payment have been fully done "(paidtodate <> doctotal)", if it has been partially paid it will still trigger the approval. If partial payment is acceptable you can change that to "paidtodate <> 0".
Hope it helps,
Jesper -
Tune the SQL Query need a Suggestion
Hi,
There is a view created which takes 17seconds to execute the query, When i split the query and execute each query takes .15 seconds to execute. Below it the query which i need to improve the performance of the code please need your suggestion in order to tweek so that time take for execution become less
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_1 "Product Name",
TRIM (UPPER (serial_number_1)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_1 != 'NULL'
AND Serial_Number_1 != 'NULL'
AND C.Amid = A.Amid(+)
UNION
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_2 "Product Name",
TRIM (UPPER (serial_number_2)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_2 != 'NULL'
AND serial_number_2 != 'NULL'
AND C.Amid = A.Amid(+)
UNION
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_3 "Product Name",
TRIM (UPPER (serial_number_3)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_3 != 'NULL'
AND serial_number_3 != 'NULL'
AND C.Amid = A.Amid(+)
UNION
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_4 "Product Name",
TRIM (UPPER (serial_number_4)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_4 != 'NULL'
AND serial_number_4 != 'NULL'
AND C.Amid = A.Amid(+)
UNION
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_5 "Product Name",
TRIM (UPPER (serial_number_5)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_5 != 'NULL'
AND serial_number_5 != 'NULL'
AND C.Amid = A.Amid(+)
UNION
SELECT 'ERP' "Source",
Imv.Bill_To "Distibutor",
Imv.Ship_To "Reseller",
Ship_To_City "Reseller City",
Ship_To_State "Reseller State",
Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'COUNTRY') "Reseller Country",
Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'THEATER') "Reseller Theater",
Cl.Company_Name "Customer Name",
Cl.City "Customer City",
Cl.State "Customer State",
Edb2_Global.Country_Name_Theater(Cl.Country,'COUNTRY') "Customer Country",
Edb2_Global.Country_Name_Theater(Cl.Country,'THEATER') "Customer Theater",
Imv.So_Booked_Date "Sales Book Date",
Imv.Ship_Date "Ship Date",
Imv.Order_Number "Sales Order Number",
Imv.Cust_Po_Number "PO Number",
Cp.Item_Name "Product Name",
Cp.Product_Serial_Number "Product Serial Number",
TO_CHAR(Imv.contract_number)"Contract ID",
Imv.Service_Description "Support Name",
Imv.Service_Start_Date "Start Date",
Imv.Service_End_Date "Expire Date",
Imv.Header_Status "Header Status",
Imv.Line_Status "Line Status",
Imv.Line_Type "Line Type",
Imv.Termination_Reason "Termination Reason",
Cl.Location_Id "Location_id",
cp.id "Product_id"
FROM ib_support_contracts_mv imv,
customer_products cp,
customer_locations cl
WHERE Upper (Trim (Imv.Serial_Number)) = Upper (Trim (Cp.Product_Serial_Number(+)))
AND Cp.Location_Id = Cl.Location_Id(+)
There is a union for each and every query, Please suggest how to tweek
Thanks
SudhirTry
select distinct a.*
from (SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_1 "Product Name",
TRIM (UPPER (serial_number_1)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_1 != 'NULL'
AND Serial_Number_1 != 'NULL'
AND C.Amid = A.Amid(+)
union all
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_2 "Product Name",
TRIM (UPPER (serial_number_2)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_2 != 'NULL'
AND serial_number_2 != 'NULL'
AND C.Amid = A.Amid(+)
union all
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_3 "Product Name",
TRIM (UPPER (serial_number_3)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_3 != 'NULL'
AND serial_number_3 != 'NULL'
AND C.Amid = A.Amid(+)
union all
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_4 "Product Name",
TRIM (UPPER (serial_number_4)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_4 != 'NULL'
AND serial_number_4 != 'NULL'
AND C.Amid = A.Amid(+)
union all
SELECT 'Parature' "Source",
NULL "Distibutor",
reseller_name "Reseller",
NULL "Reseller City",
NULL "Reseller State",
A.Country "Reseller Country",
DECODE (a.state, 'APAC', 'APAC', 'EMEA', 'EMEA', NULL, 'Unknown', 'US' ) "Reseller Theater",
NULL "Customer Name",
NULL "Customer City",
NULL "Customer State",
NULL "Customer Country",
NULL "Customer Theater",
NULL "Sales Book Date",
NULL "Ship Date",
c.sales_order_number "Sales Order Number",
C.Po_Number "PO Number",
controller_model_number_5 "Product Name",
TRIM (UPPER (serial_number_5)) "Product Serial Number",
c.contract_id "Contract ID",
product_name "Support Name",
TO_DATE (c.contract_purchase_date) "Start Date",
TO_DATE (c.contract_expiration_date) "Expire Date",
NULL "Header Status",
NULL "Line Status",
NULL "Line Type",
NULL "Termination Reason",
NULL "Location_id",
NULL "Product_id"
FROM edb_assets c,
edb_accounts a
WHERE controller_model_number_5 != 'NULL'
AND serial_number_5 != 'NULL'
AND C.Amid = A.Amid(+)
union all
SELECT 'ERP' "Source",
Imv.Bill_To "Distibutor",
Imv.Ship_To "Reseller",
Ship_To_City "Reseller City",
Ship_To_State "Reseller State",
Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'COUNTRY') "Reseller Country",
Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'THEATER') "Reseller Theater",
Cl.Company_Name "Customer Name",
Cl.City "Customer City",
Cl.State "Customer State",
Edb2_Global.Country_Name_Theater(Cl.Country,'COUNTRY') "Customer Country",
Edb2_Global.Country_Name_Theater(Cl.Country,'THEATER') "Customer Theater",
Imv.So_Booked_Date "Sales Book Date",
Imv.Ship_Date "Ship Date",
Imv.Order_Number "Sales Order Number",
Imv.Cust_Po_Number "PO Number",
Cp.Item_Name "Product Name",
Cp.Product_Serial_Number "Product Serial Number",
TO_CHAR(Imv.contract_number)"Contract ID",
Imv.Service_Description "Support Name",
Imv.Service_Start_Date "Start Date",
Imv.Service_End_Date "Expire Date",
Imv.Header_Status "Header Status",
Imv.Line_Status "Line Status",
Imv.Line_Type "Line Type",
Imv.Termination_Reason "Termination Reason",
Cl.Location_Id "Location_id",
cp.id "Product_id"
FROM ib_support_contracts_mv imv,
customer_products cp,
customer_locations cl
WHERE Upper (Trim (Imv.Serial_Number)) = Upper (Trim (Cp.Product_Serial_Number(+)))
AND Cp.Location_Id = Cl.Location_Id(+)) a
Edited by: HuaMin on May 9, 2012 2:58 PM -
Solution for a SQL Query needed immediately
Dear Friends...
I am in help of a solution for the Query which has been asked me in an interview..I failed to find the solution for the query mention below..
Query...
col1 col2
a 0
a 0
a 0
a 0
b 0
b 0
b 0
c 0
c 0
d 0
write a query to get the output as
col2 value shud be the no of occurences of col1 values...
Solution shud be like this
col1 col2
a 4
a 4
a 4
a 4
b 3
b 3
b 3
c 2
c 2
d 1
Kindly anybody plz do give me the solution immediately..
SrinivasSet up the table
SQL> create table a ( col1 CHAR(1) );
Table created.
<< insert data >>
SQL> select * from a;
C
a
a
a
a
b
b
b
c
c
d
10 rows selected.A SELECT statement with a simple GROUP BY will get counts for each letter
1 select col1, count(*)
2 from a
3* group by col1
SQL> /
C COUNT(*)
a 4
b 3
c 2
d 1Now, join that GROUP BY statement to the original table
SQL> ed
Wrote file afiedt.buf
1 select a.col1, grp_a.cnt
2 from a,
3 (select col1, count(*) cnt
4 from a
5 group by col1) grp_a
6* where a.col1 = grp_a.col1
SQL> /
C CNT
a 4
a 4
a 4
a 4
b 3
b 3
b 3
c 2
c 2
d 1
10 rows selected.Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Need to identify from whom/where row on particular table inserted
Hi,
There is master table having 60 rows but each day one row inserted in this table which is not at all required from businees prospective and we do not know from where this row inserted ?
can any body help me to identify from where this one row inserted may be by auditing OR triggers ?
appreciated for help
Thanks
prakashuser12194321 wrote:
Hi,
There is master table having 60 rows but each day one row inserted in this table which is not at all required from businees prospective and we do not know from where this row inserted ?
can any body help me to identify from where this one row inserted may be by auditing OR triggers ?
appreciated for help
Thanks
prakashDBMS_LOGMNR -
hi,
I have two tables.
tbl1
col1 col2
a 2
a 3
b 4
tbl1
col1 col2
a 3
b 5
i need to update table1 records with the value present in table. means after updation table1 record should be
tbl1
col1 col2
a 3
a 3
b 5
its pretty simple but i am not getting the answer. Thnks in advance for help.
AshishA quick, yet dirty solution:
Update
tbl1 t1
Set
t1.col2 =
case
when (select t2.col2 from tbl2 t2 where t1.col1=t2.col1) is null
then (select max(t3.col2) from tbl1 t3 where t1.col1=t3.col1)
else (select t2.col2 from tbl2 t2 where t1.col1=t2.col1)
end;
Maybe you are looking for
-
Requests per minute in idle conditions in EM
Hello Gurus, We are having an issue where in our Financial Reporting server is going down after throwing an Out of memory error in the logs in Weblogic. We have been monitoring the Financial Reporting service in the Weblogic console and in the Enterp
-
How to control numbers of characters in a input field?
Hi all I need to limit the maximum of input characters to 255 in the field: vendortxt at the Shopping Cart. Do anyone know how to do this. Regards, Bjarne
-
Anyone familiar with TotalCode for Premiere?
Anyone familiar with TotalCode for Premiere? http://www.rovicorp.com/products/distribution/content-production-tools/totalcode-for-adobe -premiere-pro.htm#overview
-
How to escape bluecove preverify error on mobile with javaFX?
Hi all, I'm finding a problem with an application that runs for a standard execution but not on mobile emulator. I am having the following error at execution. Error preverifying class com.intel.bluetooth.btgoep.Connection java/lang/NoClassDefFoundErr
-
HT5163 my ipad 2 is showing a no sim card message.....any help
My ipad 2 has been acting funny since i upgraded to IOS 7. Its been saying no sim card installed, even though there is a sim card in it I have replaced the sim card, but its still saying same Any help