Query to Group records based on
Hello,
I need a help.
I have a errortable with 4 columns (pk, errordate, activestatus, errormsg). I need to get a count of the records with a pattern of errormsg but im getting lost on this, not sure where is the problem.
For example there are records with errormsg column which has logged some error msgs like say
'xxxIn-Housexxx'
'yyyCheckedInyyy',
aaaIn-Hoouseaaa',
bbbCheckedInbbb'
I'm only interested to have a count of all those with the pattern match of 'In-House' and 'CheckedIn'
this is the one i was trying, which is giving me some syntax error not sure what it is
select count(*) from error_table where errordate > sysdate - 3
group by errormsg
having
errormsg like '%In-House%'
or
errormsg like '%CheckedIn%'
I'm really confused to get a working sql for this. can you please help me.
thanks
select sum(case
when upper(errormsg) like '%IN-HOUSE%' then 1
else 0
end
) in_house_error
,sum(case
when upper(errormsg) like '%CHECKEDIN%' then 1
else 0
end
) checkedin_error
from error_table
where errordate > sysdate - 3
;
Similar Messages
-
Grouping records based on and ID
I am trying to build a report that will segment based on a free text field which is used as an identifier between multple records.
For example I might have three records which each contrain the same id number however the record might have varying values in other fields. I want to build a report that will group all those 3 reports together under the heading of the ID and list the 3 reports. If I have other records that are linked by the ID to other records then I want them to group as well. This can be seen below
ID 001
Name Country ID
xyz USA 001
ID 002
abc Canada 002
Abc2 USA 002
ID 003
Efg1 USA 003
Efg2 Mexico
ThanksHi,
Try using a pivot table and put the id column under sections. I think that should help.
All the best.
Garima -
hi,
i have records like this
supplier,product, persons involved
10,150,[email protected]
30,200,[email protected]
20,111,[email protected]
40,211,[email protected]
i want to write a query which displays values like this
10,30,40,[email protected]
for [email protected] if there are n number of suppliers all need to be concatenated as shown above.
can any one help me on thisIts a Typical String Aggregation Question.
[String Aggregation Techniques|http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php] might be an interesting read for you.
SQL> With Test_Tab as
2 (
3 SELECT 10 supplier,150 product, '[email protected]' persons_involved FROM Dual
4 UNION ALL
5 SELECT 30,200,'[email protected]' FROM Dual
6 UNION ALL
7 SELECT 20,111,'[email protected]' FROM Dual
8 UNION ALL
9 SELECT 40,211,'[email protected]' FROM Dual
10 )
11 -- end of test data
12 SELECT persons_involved,
13 LTRIM (
14 MAX (SYS_CONNECT_BY_PATH (supplier, ','))
15 KEEP (DENSE_RANK LAST ORDER BY curr),
16 ','
17 )
18 AS suppliers_involved
19 FROM (SELECT persons_involved,
20 supplier,
21 ROW_NUMBER ()
22 OVER (PARTITION BY persons_involved ORDER BY supplier)
23 AS curr,
24 ROW_NUMBER ()
25 OVER (PARTITION BY persons_involved ORDER BY supplier)
26 - 1
27 AS prev
28 FROM test_tab)
29 GROUP BY persons_involved
30 CONNECT BY prev = PRIOR curr AND persons_involved = PRIOR persons_involved
31 START WITH curr = 1;
PERSONS_INVOLVE SUPPLIERS_INVOLVED
[email protected] 20
[email protected] 10,30,40
2 rows selected.
SQL>Hope this helps.
Regards,
Jo -
Query to group dates based on days of week
Hi,
I have a table containing the following format:
Create table testtable(dates date, day_identifier number);
The day_identifier column data contains the corresponding dates columns' day of week equivalent i.e.
to_char(dates, 'd')
The table contains following sample data:
Dates
Day_identifier
01-Oct-2013
3
02-Oct-2013
4
04-Oct-2013
6
06-Oct-2013
1
08-Oct-2013
3
09-Oct-2013
4
11-Oct-2013
6
18-Oct-2013
6
21-Oct-2013
2
23-Oct-2013
4
I am looking for a query that will group the above data based on the day_identifier column data into the following format:
01-Oct-2013 11-Oct-2013 1346
18-Oct-2013 23-Oct-2013 246
The above data if expanded i.e.
all dates between 01-Oct-2013 and 11-Oct-2013 and having day of week value in 1,3,4,6
and
all dates between 18-Oct-2013 and 23-Oct-2013 and having day of week value in 2,4,6
will give me the above table's resultset.
Please help me in resolving the issue.
Thanks.with
groups as
(select 'one' grp,
to_date('01-Oct-2013','dd-Mon-yyyy') low_date,
to_date('06-Oct-2013','dd-Mon-yyyy') high_date,
'3,5,7' day_identifiers from dual union all
select 'two',to_date('10-Oct-2013','dd-Mon-yyyy'),to_date('16-Oct-2013','dd-Mon-yyyy'),'1,2' from dual union all
select 'six',to_date('20-Oct-2013','dd-Mon-yyyy'),to_date('26-Oct-2013','dd-Mon-yyyy'),'4,5,6' from dual
dates as
(select trunc(sysdate,'mm') + level - 1 the_date,to_char(trunc(sysdate,'mm') - level - 1,'d') day_identifier
from dual
connect by level <= to_number(to_char(last_day(sysdate),'dd'))
select d.the_date,d.day_identifier,g.grp,g.low_date,g.high_date,g.day_identifiers
from dates d,
groups g
where d.the_date between g.low_date(+) and g.high_date(+)
and instr(','||g.day_identifiers(+)||',',','||d.day_identifier||',') > 0
THE_DATE
DAY_IDENTIFIER
GRP
LOW_DATE
HIGH_DATE
DAY_IDENTIFIERS
10/01/2013
1
10/02/2013
7
one
10/01/2013
10/06/2013
3,5,7
10/03/2013
6
10/04/2013
5
one
10/01/2013
10/06/2013
3,5,7
10/05/2013
4
10/06/2013
3
one
10/01/2013
10/06/2013
3,5,7
10/07/2013
2
10/08/2013
1
10/09/2013
7
10/10/2013
6
10/11/2013
5
10/12/2013
4
10/13/2013
3
10/14/2013
2
two
10/10/2013
10/16/2013
1,2
10/15/2013
1
two
10/10/2013
10/16/2013
1,2
10/16/2013
7
10/17/2013
6
10/18/2013
5
10/19/2013
4
10/20/2013
3
10/21/2013
2
10/22/2013
1
10/23/2013
7
10/24/2013
6
six
10/20/2013
10/26/2013
4,5,6
10/25/2013
5
six
10/20/2013
10/26/2013
4,5,6
10/26/2013
4
six
10/20/2013
10/26/2013
4,5,6
10/27/2013
3
10/28/2013
2
10/29/2013
1
10/30/2013
7
10/31/2013
6
Regards
Etbin -
Query to group by based on partial count match
Dear experts,
Here is a challenge question.
I have a table a on Oracle 11i – this is how it is defined.
desc a
Name Null Type
STORE_NUMBER NOT NULL CHAR(9)
ASSORTMENT_NUMBER NOT NULL CHAR(9)
ITEM_NUMBER NOT NULL CHAR(9)
DESCRIPTION CHAR(1000)
UPC_CODE NOT NULL CHAR(15)
STOCK_FLAG CHAR(1)
AVG_RTL_PRICE CHAR(16)
SALES_MOVEMENT CHAR(16)
PROD_STYLE CHAR(50)
COLOR CHAR(50)
ATT_1 CHAR(50)
ATT_2 CHAR(50)
ATT_3 CHAR(50)
ATT_4 CHAR(50)
ATT_5 CHAR(50)
ATT_6 CHAR(50)
ATT_7 CHAR(50)
ATT_8 CHAR(50)
ATT_9 CHAR(50)
ATT_10 CHAR(50)
ATT_11 CHAR(50)
ATT_12 CHAR(50)
ATT_13 CHAR(50)
ATT_14 CHAR(50)
ATT_15 CHAR(50)
25 rows selected
Primary Key as Store_number, Assortment_number, item_number. Therefore, for a particular assortment number, one store will have no two records of the same item_number.
Now, I want to add some more custom conditions to my extract from this table; we are doing this manually on an xls file by applying some formula. Wondering if we can do this by a sql query.
Here are the conditions –
1. From table a, for any particular assortment_number, count of items belonging to a store. E.g –
Count of items Store_number
5 1011
7 1022
23 1033
12 1044
2. This is more challenging. From table a, for stores with the same count of item_numbers, list down the store numbers which have the same count of items and same items in the set under them. E.g – as below.
Count of items Store_number Item_number Match Indicator Matching Stores
5 3 123|12|1234|12|1 N
5 24 123|123|123|123|123 Y 22|234
5 21 123|451|2341|234|5100 N
5 22 123|123|123|123|123 Y 24|234
5 456 123|12|1|2|3 N
5 234 123|123|123|123|123 Y 22|24
3 45 12|123|12 Y 222|150
3 432 21|34|56 Y 123
3 222 12|123|12 Y 45|150
3 123 21|34|56 Y 432
3 150 12|123|12 Y 45|222
The above table may get positions shifted to its left due to formatting.
Appreciate your time and effort.
Thank You.create table tmp_storeaggbyitem as
select
ltrim(trim(a.store_number),0) as store,
ltrim(trim(a.item_number),0) as item
from guide_pog_item_mstr a
where ltrim(trim(a.assortment_number),0) = '25571'
)Sample data in the table looks like this -
Store Item
49 59310
49 59315
49 59114
49 59295
63 59310
63 59315
63 59314
63 59308
138 59310
138 59315
138 59114
138 59295
174 8399
174 6132
174 6129
174 6137
174 6175
270 8399
270 6132
270 6129
270 6137
270 6175
343 8399
343 6132
343 6129
343 6137
343 6175Here is the result set I am looking for -
Store Count of Items Item Matching Stores
49 4 59310|59315|59114|59295 49|138
63 4 59310|59315|59314|59308 None
138 4 59310|59315|59114|59295 49|138
174 5 8399|6132|6129|6137|6175 174|270|343
270 5 8399|6132|6129|6137|6175 174|270|343
343 5 8399|6132|6129|6137|6175 174|270|343
.....Which version of the database are you using? The LISTAGG fucntuion (which is avaialble in Oracle 11.2, but not in 11.1) might be helpful here.
>
We are using Oracle Enterprise Edition 11.2.0.1.0 - 64 bit
Pl/Sql release 11.1.0.1.0
>
Why are you using the CHAR datatype instead of VARCHAR2? It may have nothing to do with this prolem, but it will cause other problems.
>
Agreed. I asked the same to my design team I inherited this table from. We are working out on the new table soon.
Thanks, Sanders. -
Query - Remove duplicate records based on value of one field
Hi,
Pleae see the data below,
how to remove records when its count 0
AND those records (name ) repeat with count > 0
existing data
name loc count
aaa a1 10
aaa a1 0
bbb b1 0
ccc c1 0
dcc d1 11
dcc d1 0
required output
name loc count
aaa a1 10
bbb b1 0
ccc c1 0
dcc d1 11
remove these records -
aaa a1 0
dcc d1 0Thanks.i assume that loc always corresponds to name. So to find the rows to remain is just a simple group by
with data as(
select 'aaa' name,'a1' loc,10 count from dual union all
select 'aaa','a1',0 from dual union all
select 'bbb','b1',0 from dual union all
select 'ccc','c1',0 from dual union all
select 'dcc','d1',11 from dual union all
select 'dcc','d1',0 from dual )
select
name
, loc
, max(count) cnt
from data
group by
name
, loc
order by
name
, loc
NAME LOC CNT
aaa a1 10
bbb b1 0
ccc c1 0
dcc d1 11to find the other is just a minus
with data as(
select 'aaa' name,'a1' loc,10 count from dual union all
select 'aaa','a1',0 from dual union all
select 'bbb','b1',0 from dual union all
select 'ccc','c1',0 from dual union all
select 'dcc','d1',11 from dual union all
select 'dcc','d1',0 from dual )
select name,loc,count from data
minus
select
name
, loc
, max(count) cnt
from data
group by
name
, loc
order by
name
, loc
NAME LOC COUNT
aaa a1 0
dcc d1 0so a delete would be
delete from data
where
(name,loc,count)
in
(select name,loc,count from data
minus ..regards -
How to get query from a record group
HI
do we get the query from which record groupis based on in oracle forms with out checking in to the properties.Hello,
No, you cannot get the initial SELECT order from the Record Group.
Francois -
SQL Query to retrieve the All records based on the Max Dates.
Hello all,
I am trying to retrieve the newest record based on the date field ( nextDate ).
Currently there are only 4 records in the MC_Maintenance table and two in the Machine table.
Machine table
MC_id EquipID
1 0227
MC_id EquipID
2 0228
MC_Maintenance table
Maint_id MC_id Next_maint
1 2 08/25/2010
2 2 07/01/2010
3 1 06/11/2010
4 1 07/11/2010
What I am trying to accomplish is,
list the two machines from the Machine table with the MAX(Next_maint) controlling the MC_Maintenance output list
These are the records that I would like to Display.
Maint_id MC_id Next_maint
1 2 08/25/2010
4 1 07/11/2010
Below is the SQL Query
SELECT
MC.MC_ID as ID,
MC.complete_Date as completed,
MC.next_maint as nextDate,
MC.maint_notes as Notes,
MC.facility as Facility,
M.EquipId,
M.name as name,
M.SerialNumber as SN,
M.dept as dept,
M.Freq as freq
From MC_Maintenance MC, Machine M
where MC.MC_ID = M.MC_ID
' USING MAX(nextDate )
Any ideas would help.
TJI would have thought that was a simple group by problem?
SELECT M.EquipID, MC.MC_ID, Max(MC.next_maint)
FROM MC_Maintenance MC INNER JOIN Machine M ON MC.MC_ID = M.MC_ID
GROUP BY M.EquipID, MC.MC_ID -
How to select records based on Max/Min on different columns and group by
I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
a b c d e
1 1 1 2 1
1 1 1 6 4
1 1 1 6 3
when i group by a,b i am expecting the record 1 6 3
Please help me with this.. Thanks in advance....Hi,
Welcome to the forum!
962163 wrote:
I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
a b c d e
1 1 1 2 1
1 1 1 6 4
1 1 1 6 3
when i group by a,b i am expecting the record 1 6 3It looks to me like "1 6 1" is the correct answer. You're asking for the lowest value of e, and 1 is lower than 3.
Maybe you don't want MIN (e). Explain why you want 3 (that is, how you decided that 3 is the correct value for the last column) and someone will help you code it.
Edited by: Frank Kulash on Sep 28, 2012 6:17 PM
Whenever you have a problem, you should psot CREATE TABLE and INSERT statements for your sample data. That way, the people who want to help you can re-create the problem and test their ideas. It often helps to clarify the problem, too. since this is your first message, I'll do it for you:
CREATE TABLE table_x
( a NUMBER
, b NUMBER
, c NUMBER
, d NUMBER
, e NUMBER
INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 2, 1);
INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 4);
INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 3);
COMMIT; -
How to modify query statement in record grp of LOV in standard form
Hi,
We are using Service contracts in Production environment.
Duplicate rows selected for LOV query.
By adding a line userenv('language') we solve the problem.
But the coding was written inside the standard "OKSITMSL.pll". Here For the Field "NAME", LOV
record group "CUST_SYSTEM" assigned dynamically based on
other fields "ITEMSEL.FILTER = SYSTEM" and "ITEMSEL.CUSTOMER_FILTER = CUSTOMER".
I have added piece of the details below.
Form is Standard form "OKSITMSL", Which is calling om parent form "OKSAUDET".
Form : OKSITMSL
Block : ITEMSEL
field : NAME
pll : OKSITMSL.pll
oksitmsl.pll coding-------------
ELSIF NAME_IN('ITEMSEL.FILTER') = 'System' THEN
If UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'CUSTOMER' then
l_group_name := 'CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'RELATED' then
l_group_name := 'REL_CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'BOTH' then
l_group_name := 'BOTH_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'ALL' then
l_group_name := 'OKS_SYSTEM';
End If;
Set_Lov_Property('ITEMSEL_LEVEL', GROUP_NAME, l_group_name);
âCUST_SYSTEMâ Record group present in âOKSITMSLâ form.
I need the advice how to solve my problem by adding a line in query of "CUST_SYSTEM" record group without touching/alter standard form.
Thanks in advance.
Navasthank you shadow,
I think you mean like below:
and trim(leading 0 from a.DD_DRX_BSID_NID) = nvl(trim(to_char(SUBSTR('00042',6,5),'XXXXXXXXX')),0)
and trim(leading 0 from a.DD_DRX_BSID_BSC) = nvl(trim(to_char(SUBSTR('00042',11,5),'XXXXXXXXX')),0) ))But i think it compares with all 0's record ... but that's not correct
Edited by: josh1612 on Dec 22, 2008 2:50 AM -
Query about multi record block
Abdetu
Please clarify this
I have a multi record group on the canvas, which displays 5 records at a time. The block is based on a table. All the items, except 3 items are displayed items.Now in the block I have a list item, in which I have two values "PO" and "TSF".. If user selects PO, associated text items will get enabled and user will be entering the values .. Same is the case with TSF .. And at the end user selects Ok button to save the record to the database
Now while fetching the records (based on query) ..once the records are fetched, control will be on PO/TSF list box, now the user can either change PO to TSF or TSF to PO ..or he/she may opt not to change also.. If user changes PO to TSF, only that particular record's TSF fields should get enabled .. The problem what I am facing is, when the control comes to PO/TSF list box.. since its multi record block, all the record's PO/TSF list box are getting enabled
In the sense, if control is in the 1st record of multi record block, only those fields should get enabled, once the user navigates to the text item which is the last of that particular record, then 2nd record should get enabled....
Can I know the solution
Regards
Message was edited by:
Seshu
Message was edited by:
SeshuHello Seshu
ur case explanation should be in points 1,2,etc as possible leaving extra lines and spaces in between .. and the case should be more clear and summarized like:
1- I have multi-records data block.
2- I have a static list item with 2 values eg. (a and b).
3- Depending on selecting from the list some items r enabled.etc.
Kindly note that, this will facilitate ur problem to be more readable,recognizable and save time and effort of someone who wants to help u.
Here comes the confusion:
Now while fetching the records (based on query)
The problem what I am facing is, when the control comes to PO/TSF list box.. >since its multi record block, all the record's PO/TSF list box are getting enabled i think with the piece of code i have just posted to u this can't be happened since it disable all the record's PO/TSF.
if this didn't solve ur problem i suggest either u post ur code to help u or u try to put some validations with :
if statment inside the loop depending on the list item's values which will enable or disable related items to the list.
Hope this help u,
If any Questions pls let me know..
Regards,
Abdetu.. -
Query not considering function based index in oracle 11g
I have a query which used Function Based Index when run in oracle 9i but when I run the same query
without any changes, it does not consider index. Below is the query:
SELECT distinct patient_role.domain_key, patient_role.patient_role_key,
patient_role.emergency_contact_name,
patient_role.emergency_contact_phone, patient_role.emergency_contact_note,
patient_role.emergency_contact_relation_id,
patient_role.financial_class_desc_id, no_known_allergies, patient_role.CREATED_BY,
patient_role.CREATED_TIMESTAMP,
patient_role.CREATED_TIMESTAMP_TZ, patient_role.UPDATED_BY, patient_role.UPDATED_TIMESTAMP,
patient_role.UPDATED_TIMESTAMP_TZ,
patient_role.discontinued_date
FROM encounter, patient_role
WHERE patient_role.patient_role_key = encounter.patient_role_key
AND UPPER(TRIM(leading :SYS_B_0 from encounter.account_number)) = UPPER(TRIM(leading :SYS_B_1 from
:SYS_B_2))
AND patient_role.discontinued_date IS null
AND encounter.discontinued_date IS null ;
Index definition:
CREATE INDEX "user1"."IX_TRIM_ACCOUNT_NUMBER" ON "user1."ENCOUNTER" (UPPER(TRIM(LEADING
'0' FROM "ACCOUNT_NUMBER")), "PATIENT_ROLE_KEY", "DOMAIN_KEY", "DISCONTINUED_DATE")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT)
TABLESPACE "user1"
Database : Oracle 11g (11.2.0.3)
O/S : Linux 64 bit (the query does not consider index even on windows os)
Any suggestions?
-Onkar
Edited by: onkar.nath on Jul 2, 2012 3:32 PMOnkar,
I don't appreciate you posting this question in several forums at the same time.
If I would know you also posted this on Asktom, I wouldn't even have bothered.
As to your 'issue':
First of all: somehow cursor_sharing MUST have been set to FORCE. Oracle is a predictable system, not a fruitmachine.
Your statement the '0' is replaced by a bind variable anyway is simply false. If you really believe it is not false, SUBMIT a SR.
But your real issue is not Oracle: it is your 'application', which is a mess anyway. Allowing for alphanumeric numbers is a really bad idea.
Right now you are already putting workaround on workaround on workaround on workaround.
Issue is the application: it is terminal., and you either need to kill it, or to replace it.
Sybrand Bakker
Senior Oracle DBA -
How Journal Import groups records from GL_INTERFACE into Journal Headers
Hello,
Does anyone know how or using what criteria the Journal Import program groups records from the GL_INTERFACE into Journal Entries?
The R12 User Guide says that :
REFERENCE4 (Journal entry name): Enter a journal entry name for your journal entry.
Journal Import creates a default journal entry name using the following format:
(Category Name) (Currency) (Encumbrance Type ID, if applicable) (Currency
Conversion Rate, if applicable) (Currency Conversion Date, if applicable) (Originating
Balancing Segment Value), chopped to the first 100 characters. If the above results in
multiple journals in the same batch with the same name, then additional characters are
chopped off, and a 2, 3, 4, and so on, is added for the second, third, fourth, journals with
the same name.
Does it mean that for every unique combination of Category+Currency+CurrencyConversion Rate+Currency Conversion Date, a Journal Header would be created? I also found that although not mentioned in the user guide, if the Accounting Date within a group of records is different, the import program includes accounting date to the above criteria and tries to create separate Journal headers per Accounting Date.
Also, is there a way to override this ( Category+Currency+CurrencyConversion Rate+Currency Conversion Date) criteria?
Thanks,
Manishany suggessions on the above query?
Thanks & regards
Aboo -
How to omit records based on a status code
I am trying to select records based on a status 'N' or 'A' by a certain date as long as by the chosen date there is not another status given to the same course like 'D' or 'X'.
Here are some sample data...
CREATE TABLE #TEST
(ID VARCHAR(7),
COURSE VARCHAR(10),
CURRENT_STATUS VARCHAR(1),
STATUS_DATE DATETIME)
INSERT INTO #TEST
(ID, COURSE, CURRENT_STATUS, STATUS_DATE)
VALUES
('0020541','AAAA-1000H', 'X', '2013-08-27 00:00:00.000'),
('0020541','AAAA-1000H', 'N', '2013-08-26 00:00:00.000'),
('0020541','BBBB-2000H', 'D', '2013-11-04 00:00:00.000'),
('0020541','BBBB-2000H', 'N', '2013-08-27 00:00:00.000'),
('0020541','CCCC-3000H', 'D', '2013-09-11 00:00:00.000'),
('0020541','CCCC-3000H', 'N', '2013-08-26 00:00:00.000'),
('0020541','DDDD-4000H', 'A', '2013-08-25 00:00:00.000'),
('0020541','EEEE-5000H', 'N', '2013-08-26 00:00:00.000')
SELECT * FROM #TEST
DROP TABLE #TEST
If the query is to determine how many records with a status of N or A up to and incl August 26, 2013, I should see 4 records... AAAA-1000H, CCCC-3000H, DDDD-4000H, EEEE-5000H
If the query is to determine how many records with a status of N or A up to and incl October 1, 2013, I should see 3 records... BBBB-2000H, DDDD-4000H, EEEE-5000H
...and so on.
Any help is appreciated.I am trying to select records based on a status 'N' or 'A' by a certain date as long as by the chosen date there is not another status given to the same course like 'D' or 'X'.
Here are some sample data...
CREATE TABLE #TEST
(ID VARCHAR(7),
COURSE VARCHAR(10),
CURRENT_STATUS VARCHAR(1),
STATUS_DATE DATETIME)
INSERT INTO #TEST
(ID, COURSE, CURRENT_STATUS, STATUS_DATE)
VALUES
('0020541','AAAA-1000H', 'X', '2013-08-27 00:00:00.000'),
('0020541','AAAA-1000H', 'N', '2013-08-26 00:00:00.000'),
('0020541','BBBB-2000H', 'D', '2013-11-04 00:00:00.000'),
('0020541','BBBB-2000H', 'N', '2013-08-27 00:00:00.000'),
('0020541','CCCC-3000H', 'D', '2013-09-11 00:00:00.000'),
('0020541','CCCC-3000H', 'N', '2013-08-26 00:00:00.000'),
('0020541','DDDD-4000H', 'A', '2013-08-25 00:00:00.000'),
('0020541','EEEE-5000H', 'N', '2013-08-26 00:00:00.000')
SELECT * FROM #TEST
DROP TABLE #TEST
If the query is to determine how many records with a status of N or A up to and incl August 26, 2013, I should see 4 records... AAAA-1000H, CCCC-3000H, DDDD-4000H, EEEE-5000H
If the query is to determine how many records with a status of N or A up to and incl October 1, 2013, I should see 3 records... BBBB-2000H, DDDD-4000H, EEEE-5000H
...and so on.
Any help is appreciated.
I guess I didn't understand your problem. Not sure if this might help you.
SELECT * FROM #TEST
where CURRENT_STATUS IN ('N','A') AND STATUS_DATE<='2013-08-26'
AND STATUS_DATE NOT IN(Select STATUS_DATE from #test
where CURRENT_STATUS IN ('D','X'))
SELECT * FROM #TEST
where CURRENT_STATUS IN ('N','A')
AND STATUS_DATE<='2013-10-01'
AND STATUS_DATE NOT IN(Select STATUS_DATE from #test
where CURRENT_STATUS IN ('D','X'))
- please mark correct answers -
Select records based on criteria and update those records once read
hi,
I am very new to bpel and DB adapters.
I have a requirement where in I need to query two tables to fetch some records and update these selected records with a new value for field to indicate that bpel has processed these records.
Once I select these I needs the output to be mapped to the output variable.
I am able to select the records based on criteria , but how will i lock these records so that these records do not get processed again. This should be a very simple usecase just that I am not aware.
Thanks,
RobinOnce you have finished reading the records fire an update query , update some field in the table so that it does not get picked up next time.
if you are using polling for picking up the records, then use logical delete scenario, refer....http://docs.oracle.com/cd/E15523_01/integration.1111/e10231/adptr_db.htm#BABEEBIH
Maybe you are looking for
-
Change Reconciliation Account for customer.
Hi All, I want to change the Reconciliation Account for customer. it is giving me message that Account has been posted to; hold balance sheet adjustment (Message no. F2067). How do I change it. Thanks Utpal.
-
Can we rename the folder !SSL!
Hello Linux causes problems because of the special cases in the help file name. I link the html file to my system using the full path, for example: \Online_Help\ECC\!SSL!\WebHelp\introduction.htm If I change the name of the folder !SSL!, will that ca
-
BW web short dump error msg RABAX_STATE
Hi I am geeting the erroe msg while iam ececuting the web report... ote The following error text was processed in the system PW1 : Maximum number of open files exceeded. The error occurred on the application server ZRTPH0U2_PW1_35 and in the work pro
-
Things in my browser are miss sized. Every thing seems disproportional in size except for the actual web pages
-
Child Objects and TopLink Cache
All, I have a problem RE the TopLink cache: Object A has a Vector of Object Bs (1:M) and Object B has a Vector of Object Cs(1:M). I am using ValueHolderInterface and indirection pattern for each of these Vectors. When I update an Object C, it is not