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
Thanks
Hi,
Try using a pivot table and put the id column under sections. I think that should help.
All the best.
Garima
Similar Messages
-
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.
thanksselect 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
; -
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; -
I've found no way to sort search results in itunes. For example, if I type the group "Rush" into the search bar, I get a list of songs recorded by rush and literally thousands of other songs and artists with the word rush in them. There is; however, no way to sort the results.
In the Search box click on the black Arrow and UNTICK the Search Entire Library.
Then the Search results in Songs view will be displayed in the main Grid and you can sort them by clicking on the column headers.
You can also turn on the column browser which can help with filtering -
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 -
Order of records - finding preceding and next records
I have looked around a few forums for a similar question but I'm not really even sure what to search for!
I have a table with some events, client names, timestamps for the event, and a category. There are four steps in a cycle.
CREATE TABLE #events (EventID INT IDENTITY(1, 1),
Client VARCHAR(10),
RecordTimestamp DATETIME,
Step TINYINT)
INSERT INTO #events (Client,
RecordTimestamp,
Step)
VALUES ('Client A', '01-01-2014', 1),
('Client A', '01-02-2014', 2),
('Client A', '01-03-2014', 3),
('Client A', '01-04-2014', 4),
('Client A', '01-05-2014', 1),
('Client A', '01-06-2014', 2),
('Client B', '01-04-2014', 1),
('Client B', '01-06-2014', 2)
SELECT *
FROM #events
ORDER BY RecordTimestamp, Client
So let's assume that step 2 cannot start for a given client until step 1 completes, category 3 can't start until 2 completes, etc. If today is 1/7/2014 we could say that Client A has completed one full cycle (steps 1-4), Client A is
half way through cycle 2, and Client B is half way through its first cycle.
I'm trying to identify all cycles that are in progress, meaning a step 1, 2, or 3 is present without a step 4 record (by client). A query on the data above would return step 2 of Client A and Client B, both on 1/6. I no longer care about the
first cycle from Client A because another cycle has started.
The table columns can be changed if necessary. Can someone at least push me in the right direction? It may involve a CTE and/or cursor, but I'm just not sure where to start.
Thanks!> I provided the example above as a slightly simplified version of what I'm working on
Not good, you should provide a something closer to what you are working on.
I read from your original post that "There are four steps in a cycle." and I see that you enumerate them 1 - 4 and also read that "So let's assume that step 2 cannot start
for a given client until step 1 completes, category 3 can't start until 2 completes, etc.", so based on those facts I decided to enumerate all steps for each customer (rn1) and used the formula (rn - 1) / 4 to identify blocks
of steps (groups of consecutive steps):
row rn1 (rn1 - 1) / 4
('Client A', '01-01-2014', 1) 1 0
('Client A', '01-02-2014', 2) 2 0
('Client A', '01-03-2014', 3) 3 0
('Client A', '01-04-2014', 4) 4 0
('Client A', '01-05-2014', 1) 5 1
('Client A', '01-06-2014', 2) 6 1
('Client B', '01-04-2014', 1) 1 0
('Client B', '01-06-2014', 2) 2 0
Then for each group we enumerate again (rn2) but this time in descending order (rn DESC) so the last step in each group will be the first row based on the new enumeration. Now we can select those rows where rn2 = 1 but only if the step number is not 4.
If your data is different, for example steps numbers go from 10 to 40 in increments of 10 then you have to change the logic slightly:
SET NOCOUNT ON;
USE tempdb;
GO
CREATE TABLE #events (
EventID INT IDENTITY(1, 1),
Client VARCHAR(10),
RecordTimestamp DATETIME,
Step tinyint,
UNIQUE CLUSTERED (Client, RecordTimestamp, Step)
INSERT INTO #events (Client,
RecordTimestamp,
Step)
VALUES
('Client A', '01-01-2014', 10),
('Client A', '01-02-2014', 20),
('Client A', '01-03-2014', 30),
('Client A', '01-04-2014', 40),
('Client A', '01-05-2014', 10),
('Client A', '01-06-2014', 20),
('Client B', '01-04-2014', 10),
('Client B', '01-06-2014', 20);
SELECT *
FROM #events
ORDER BY RecordTimestamp, Client
GO
WITH C1 AS (
SELECT
ROW_NUMBER() OVER(PARTITION BY Client ORDER BY RecordTimestamp, Step) AS rn1
FROM
#events
C2 AS (
SELECT
ROW_NUMBER() OVER(PARTITION BY Client, (rn1 - 1) / 4 ORDER BY rn1 DESC) AS rn2
FROM
C1
SELECT
EventID,
Client,
RecordTimestamp,
Step
FROM
C2
WHERE
rn2 = 1 AND Step < 40;
GO
DROP TABLE #events;
GO
If you can have 8 steps and the maximum one is 80 then the logic should be:
SET NOCOUNT ON;
USE tempdb;
GO
CREATE TABLE #events (
EventID INT IDENTITY(1, 1),
Client VARCHAR(10),
RecordTimestamp DATETIME,
Step tinyint,
UNIQUE CLUSTERED (Client, RecordTimestamp, Step)
INSERT INTO #events (Client,
RecordTimestamp,
Step)
VALUES
('Client A', '01-01-2014', 10),
('Client A', '01-02-2014', 20),
('Client A', '01-03-2014', 30),
('Client A', '01-04-2014', 40),
('Client A', '01-05-2014', 50),
('Client A', '01-06-2014', 60),
('Client A', '01-07-2014', 70),
('Client A', '01-08-2014', 80),
('Client A', '01-09-2014', 10),
('Client A', '01-10-2014', 20),
('Client B', '01-04-2014', 10),
('Client B', '01-06-2014', 20);
SELECT *
FROM #events
ORDER BY RecordTimestamp, Client
GO
WITH C1 AS (
SELECT
ROW_NUMBER() OVER(PARTITION BY Client ORDER BY RecordTimestamp, Step) AS rn1
FROM
#events
C2 AS (
SELECT
ROW_NUMBER() OVER(PARTITION BY Client, (rn1 - 1) / 8 ORDER BY rn1 DESC) AS rn2
FROM
C1
SELECT
EventID,
Client,
RecordTimestamp,
Step
FROM
C2
WHERE
rn2 = 1 AND Step < 80;
GO
DROP TABLE #events;
GO
If you want to show the last non-completed group for each client and from there the first and last steps then try:
SET NOCOUNT ON;
USE tempdb;
GO
CREATE TABLE #events (
EventID INT IDENTITY(1, 1),
Client VARCHAR(10),
RecordTimestamp DATETIME,
Step tinyint
INSERT INTO #events (Client,
RecordTimestamp,
Step)
VALUES
('Client A', '01-01-2014', 10),
('Client A', '01-02-2014', 20),
('Client A', '01-03-2014', 30),
('Client A', '01-04-2014', 40),
('Client A', '01-05-2014', 50),
('Client A', '01-06-2014', 60),
('Client A', '01-07-2014', 70),
('Client A', '01-08-2014', 80),
('Client A', '01-09-2014', 10),
('Client A', '01-10-2014', 20),
('Client A', '01-11-2014', 30),
('Client B', '01-04-2014', 10),
('Client B', '01-06-2014', 20);
SELECT *
FROM #events
ORDER BY RecordTimestamp, Client
GO
WITH C1 AS (
SELECT
ROW_NUMBER() OVER(PARTITION BY Client ORDER BY RecordTimestamp, Step) AS rn1
FROM
#events
C2 AS (
SELECT
DENSE_RANK() OVER(PARTITION BY Client ORDER BY (rn1 - 1) / 8 DESC) AS grp,
ROW_NUMBER() OVER(PARTITION BY Client, (rn1 - 1) / 8 ORDER BY rn1) AS rn2,
ROW_NUMBER() OVER(PARTITION BY Client, (rn1 - 1) / 8 ORDER BY rn1 DESC) AS rn3
FROM
C1
SELECT
EventID,
Client,
RecordTimestamp,
Step
FROM
C2
WHERE
grp = 1 AND 1 IN (rn2, rn3) AND Step < 80
ORDER BY
Client,
EventID;
GO
DROP TABLE #events;
GO
If you check the execution plan you will notice several SORT operators which could yield poor performance. We could try using an intermediate table and adding a POC (partition / ordering / covering - idea from ITzik Ben-Gan) index to improve it.
Does this help?
AMB
Some guidelines for posting questions... -
Delete duplicate records based on condition
Hi Friends,
I am scratching my head as how to select one record from a group of duplicate records based upon column condition.
Let's say I have a table with following data :
ID START_DATE END_DATE ITEM_ID MULT RETAIL | RETAIL / MULT
1 10/17/2008 1/1/2009 83 3 7 | 2.3333
2 10/17/2008 1/1/2009 83 2 4 | 2
3 10/17/2008 1/1/2009 83 2 4 | 2
4 10/31/2008 1/1/2009 89 3 6 | 2
5 10/31/2008 1/1/2009 89 4 10 | 2.5
6 10/31/2008 1/1/2009 89 4 10 | 2.5
7 10/31/2008 1/1/2009 89 6 6 | 1
8 10/17/2008 10/23/2008 124 3 6 | 2From the above records the rule to identify duplicates is based on START_DATE,+END_DATE+,+ITEM_ID+.
Hence the duplicate sets are {1,2,3} and {4,5,6,7}.
Now I want to keep one record from each duplicate set which has lowest value for retail/mult(retail divided by mult) and delete rest.
So from the above table data, for duplicate set {1,2,3}, the min(retail/mult) is 2. But records 2 & 3 have same value i.e. 2
In that case pick either of those records and delete the records 1,2 (or 3).
All this while it was pretty straight forward for which I was using the below delete statement.
DELETE FROM table_x a
WHERE ROWID >
(SELECT MIN (ROWID)
FROM table_x b
WHERE a.ID = b.ID
AND a.start_date = b.start_date
AND a.end_date = b.end_date
AND a.item_id = b.item_id);Due to sudden requirement changes I need to change my SQL.
So, experts please throw some light on how to get away from this hurdle.
Thanks,
Raj.Well, it was my mistake that I forgot to mention one more point in my earlier post.
Sentinel,
Your UPDATE perfectly works if I am updating only NEW_ID column.
But I have to update the STATUS_ID as well for these duplicate records.
ID START_DATE END_DATE ITEM_ID MULT RETAIL NEW_ID STATUS_ID | RETAIL / MULT
1 10/17/2008 1/1/2009 83 3 7 2 1 | 2.3333
2 10/17/2008 1/1/2009 83 2 4 | 2
3 10/17/2008 1/1/2009 83 2 4 2 1 | 2
4 10/31/2008 1/1/2009 89 3 6 7 1 | 2
5 10/31/2008 1/1/2009 89 4 10 7 1 | 2.5
6 10/31/2008 1/1/2009 89 4 10 7 1 | 2.5
7 10/31/2008 1/1/2009 89 6 6 | 1
8 10/17/2008 10/23/2008 124 3 6 | 2So if I have to update the status_id then there must be a where clause in the update statement.
WHERE ROW_NUM = 1
AND t2.id != t1.id
AND t2.START_DATE = t1.START_DATE
AND t2.END_DATE = t1.END_DATE
AND t2.ITEM_ID = t1.ITEM_IDInfact the entire where_ clause in the inner select statement must be in the update where clause, which makes it totally impossible as T2 is persistent only with in the first select statement.
Any thoughts please ?
I appreciate your efforts.
Definitely this is a very good learning curve. In all my experience I was always writing straight forward Update statements but not like this one. Very interesting.
Thanks,
Raj. -
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 -
Value based hierarchies and Period dimension should only contain 2 monthl
Hi,
Can anyone tell me what is value based hierarchies. And also can anyone let me know to filter the records in AWm because in Period dimension should only contain 2 monthly values (Oct. 2008 ( 200810) and Sep. 2008 ( 200809)) it is urgent.
Thanks
velThe following definition of a value hierarchy comes from the OLAP Developers guide
"A hierarchy defined only by the parent-child relationships among dimension members. The dimension members at a particular distance from the base level do not form a meaningful group for analysis, so the levels are not named. For example, an employee dimension might have a parent-child relation that identifies each employee's supervisor. However, levels that group together first-, second-, and third-level supervisors and so forth may not be meaningful for analysis."
Typically this means that the source table has two columns, VALUE and PARENT, where PARENT has a (logical) foreign key relationship to VALUE. An example may be EMPLOYEE, MANAGER, where MANAGERs are also EMPLOYEEs.
The simplest way to restrict the values loaded into the AW is to define a SQL view over the source table with an appropriate WHERE condition. You then use AWM to map the dimension to your new view. E.g.
CREATE OR REPLACE VIEW RESTRICTED_TIME AS
SELECT *
FROM TIME
WHERE MONTH IN (200810, 200809) -
Dynamically group records by date
I am attempting to create a report that will dynamically group records into a set number of date buckets. This is similar to grouping records by a date field and setting the days, weeks, months, etc property but instead of grouping by a set time span I want to a specific number of date groups regardless of date span. So say i have records where the first date is today at 1am and the last record is today at 9 pm. I want the data grouped into 10 groups and the time calculated for that group based on total time span / 10. The first group would be 1AM to 3AM, the second would group 3AM to 5AM, etc.. The reason I am doing this is for a chart that displays record counts over time but the overall timespan will never be known until runtime. Setting the chart for hourly or weekly doesn't work because if the user runs the report over a year the dates will be illegible.
Thanks in advance!Well this SHOULD be easy. But leave it to CR make not...
You can start by finding the minimum & maximum dates within your range:
Local DateTimeVar MinDate;
MinDate := Minimum({Table.DateField})
and
Local DateTimeVar MaxDate;
MaxDate := Maximum({Person.ModifiedDate})
Then figure out what the the interval would be if the span is broken down into 10 equal parts"
DateDiff("n", {@MinDate}, {@MaxDate}) / 10
From there just use a formula to segregate each records into the appropriate groups:
EvaluateAfter({@Interval});
IF {Table.DateField} >= {@MinDate}
AND {Table.DateField} <= DateAdd("n",{@Interval}, {@MinDate}) THEN 1 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval}, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 2, {@MinDate}) THEN 2 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 2, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 3, {@MinDate}) THEN 3 ELSE
IF{Table.DateField} > DateAdd("n",{@Interval} * 3, {@MinDate})
AND{Table.DateField} <= DateAdd("n",{@Interval} * 4, {@MinDate}) THEN 4 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 4, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 5, {@MinDate}) THEN 5 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 5, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 6, {@MinDate}) THEN 6 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 6, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 7, {@MinDate}) THEN 7 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 7, {@MinDate})
AND{Table.DateField} <= DateAdd("n",{@Interval} * 8, {@MinDate}) THEN 8 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 8, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 9, {@MinDate}) THEN 9 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 9, {@MinDate})
AND {Table.DateField} <= {@MaxDate} THEN 10
This is where CR drops the ball... IMHO... it WON'T allow you to to group by a formula field that uses an aggregate in the formula (in this case Minimum & Maximum)... It will however allow to to graph on it, which I assume is what you are actually trying to do. If anyone knows a way to work around the grouping issue, I'd love to know it myself.
HTH,
Jason -
Identifying records based on one or more common fields
Hi all
This should be easy - but going round in circles. I want to be able to group together records based on whether at least one field is the same as the corresponding field in a different record.
So:
Account No Tel No PostCode
ABC123 17654231 TS24 4ZX
DEF987 8764573 NE1 1AL
QWE921 17654321 SR9 8BD
ASD579 24697615 SR9 8BD
So in the above example the first, third and fourth record would all form one group because the first links to the third based on Tel No and the third links to the fourth based on PostCode. The second record will be in a group of its own. I want to output the above (into a new table) with an additional field linking relevant records together (a group number).
My first pass was to simply:
select the minimum group number from the output table where either the Tel No or Phone No match the current record. If no match then create a new record for this record with the next incremental group number.
This would give
Account No Tel No PostCode Group
ABC123 17654231 TS24 4ZX 1
DEF987 8764573 NE1 1AL 2
QWE921 17654321 SR9 8BD 1
ASD579 24697615 SR9 8BD 1
On the surface that looks OK. The problem occurs if for instance the PostCode in the second record is 'SR9 8BD'. The output would be identical to the above - but I want them to all share the same group number as now there is some commonality between all four records. I'm sure I need to do something recursively but just can't get my head around it.
Would really appreciate some help.
Thanks
IanHi, Ian,
Welcome to the forum!
Be sure to read the forum FAQ {message:id=9360002} It contains several tips that can help you get good answers quickly
976560 wrote:
Hi all
This should be easy - but going round in circles.Ironically, the solution below involves NOCYCLE.
I want to be able to group together records based on whether at least one field is the same as the corresponding field in a different record.
So:
Account No Tel No PostCode
ABC123 17654231 TS24 4ZX
DEF987 8764573 NE1 1AL
QWE921 17654321 SR9 8BD
ASD579 24697615 SR9 8BDWhenever you have a problem, please post CREATE TABLE and INSERT statments for all tables inolved. Since this is your fist message, I'll do it for you:
DROP TABLE table_x;
CREATE TABLE table_x
( Account_No VARCHAR2 (10) PRIMARY KEY
, Tel_No VARCHAR2 (10)
, Post_Code VARCHAR2 (10)
INSERT INTO table_x (account_no, tel_no, post_code)
VALUES ('ABC123', '17654321', 'TS24 4ZX');
INSERT INTO table_x (account_no, tel_no, post_code)
VALUES ('DEF987', '8764573', 'NE1 1AL');
INSERT INTO table_x (account_no, tel_no, post_code)
VALUES ('QWE921', '17654321', 'SR9 8BD');
INSERT INTO table_x (account_no, tel_no, post_code)
VALUES ('ASD579', '24697615', 'SR9 8BD');
COMMIT;
So in the above example the first, third and fourth record would all form one group because the first links to the third based on Tel No Be careful! It looks like you made a typo there. I changed the number ending in '231' to '321'.
and the third links to the fourth based on PostCode. The second record will be in a group of its own. I want to output the above (into a new table) with an additional field linking relevant records together (a group number).
My first pass was to simply:
select the minimum group number from the output table where either the Tel No or Phone No match the current record. If no match then create a new record for this record with the next incremental group number.
This would give
Account No Tel No PostCode Group
ABC123 17654231 TS24 4ZX 1
DEF987 8764573 NE1 1AL 2
QWE921 17654321 SR9 8BD 1
ASD579 24697615 SR9 8BD 1
On the surface that looks OK. The problem occurs if for instance the PostCode in the second record is 'SR9 8BD'. The output would be identical to the above - but I want them to all share the same group number as now there is some commonality between all four records. I'm sure I need to do something recursively but just can't get my head around it.You said it exactly: you need to do something recursively.
What features of Oracle SQL are recursive? CONNECT BY (as shown below) and, starting in Oracle 11.2, recursive WITH clauses.
Would really appreciate some help.Here's one way to do that:
CREATE TABLE table_y
AS
WITH got_related_account_no AS
SELECT table_x.*
, CONNECT_BY_ROOT account_no AS related_account_no
FROM table_x
CONNECT BY NOCYCLE account_no != PRIOR account_no
AND ( tel_no = PRIOR tel_no
OR post_code = PRIOR post_code
-- OR ... -- other columns as needed
SELECT account_no, tel_no, post_code
, DENSE_RANK () OVER (ORDER BY MIN (related_account_no))
AS grp
FROM got_related_account_no
GROUP BY account_no, tel_no, post_code
;This will work in Oracle 10.1 and up.
At the end of this, table_y contains:
ACCOUNT_NO TEL_NO POST_CODE GRP
ABC123 17654321 TS24 4ZX 1
ASD579 24697615 SR9 8BD 1
DEF987 8764573 NE1 1AL 2
QWE921 17654321 SR9 8BD 1 -
Splitting the single record into multiple records based on validity
Hi Guru's,
basically i am an BI consultant with less knowledge on ABAP, can i request your help on the ABAP task.
I am working on HR module which is integrated with SAP BI, the reports will be executed based on calendar month the requirement is i should split the single record into a multiple records based on validity of the record. basically the HR data would be in data from and date to.
below is the logic
Check whether the start and end date of the record are in the same month and year.
If yes nothing changes
If no create multiple records
1st record original start date of the record u2018till end of that month
Following record 1st of the next month u2018till last day of the month
u2026
Last record 1st of the month u2018till original end date.
All fields will have the same values, only the datefrom and dateto fields change.
Can any one please provide me the same code to proceed on my task.
Thanks and Regards,
VenkatHi,
Using Rule group we can split it.
Using Rule Group in SAP-BI Part - 1
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/business-intelligence/s-u/using%20rule%20group%20in%20sap-bi%20%20part%20-%201.pdf
Thanks
Reddy -
ACS 5.3 Group Mapping based on AD group membership
Hi,
I am configuring a new ACS 5.3 system. Part of the rules is that I want to match the users specific AD group membership, and match appropriatly to an identity group.
What i'm trying to do is say that if the user is a member of the AD Group (G-CRP-SEC-ENG) then associate them with the Identity Group SEC-ENG. The under the access service, authorization portion, i assign shell profiles and command sets based on Identity Group.
It seems that the ACS server will not match the AD Group for the user, and it will match the Default of teh Group Mapping portion of the policy every time.
I tried several configuration choices from : AD1:ExternalGroups contains any <string showing in AD>, AD1:memberOf <group>.
Is there something special i need to do in the Group Mapping Policy to get it to match and active directory group and result in assigning the host to an Identity Group?
Thank you,
SamiOk, my case is like this.
I use ACS 5.3 for VPN authentication, using AD and an external RSA for token authentication (2 factor authentication)
I didn't add all the VPN users in the ACS, because it will be troublesome, the users authentication will be managed by AD and RSA server.
In some cases where we need to restrict a group of user to only access certain resources, downloadable ACL is used.
Following the Cisco docs, i manage to get downloadable ACL works when the authorization profile matching criteria is username, but when i change the matching criteria to Identity group, the downloadable ACL won't work.
I have a case with Cisco engineer now and still in the middle to sort things out.
The advice from the Cisco engineer is to have the Access Service set to Internal User instead of RSA server, but that will require us(the admin) to import all the VPN users into the ACS database.
Wondering whether there is a fix for this.
Thanks. -
How to create a record based on the name of a file in the file-system?
Hi,
With a lot of pictures I want to have a database to gather some information about these pictures.
First question is how to generate a record based on a file in the file system?
e.g. the pictures are "c:\fotos\2009\01\disc_001.jpg" to "c:\foto\2009\01\dis_98.jpg" .
now i want to create records with as one of the attributes the name of the picture (not the picture itself). how to create these records (based on the information of the file-ssytem). i.e. the number of records should be the same as the number of pictures.
any suggestions?
any reaction will be appreciated.
LeoLink to Create directory
http://www.adp-gmbh.ch/ora/sql/create_directory.html
You can create a list of files in the directory and read the list files from that directory.
[UTL_FILE Documentation |http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10802/u_file.htm#996728]
[Solution using Java|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:439619916584]
SS -
Hi ,
How to find out the latest Record in per_all_people_f and per_all_assignments_f
Requirement : Need to find out the latest record in per_all_people_f and per_all_assignments_f to update the attribute column with pre defined value . Its not possible to track only with person_id / assignment_id and effective end date
SELECT pp_id
FROM (SELECT app.person_id pp_id,
asf.*
FROM apps.per_all_people_f app,
apps.per_all_assignments_f asf
WHERE --app.person_id=123568 and
asf.person_id = app.person_id AND
app.effective_end_date = to_date('31-dec-4712') AND
asf.effective_end_date = to_date('31-dec-4712')
GROUP BY app.person_id)
HAVING COUNT(pp_id) > 1
GROUP BY pp_id
This query also returns more than 1 value for person_id .
It would be great if you put comment on this .. Thanks in advance ,
AryaI am getting more records with asf.primary_flag='Y' . If you give ur mail id , i will send the sample data
ASSIGNMENT_ID EFFECTIVE_START_DATE EFFECTIVE_END_DATE BUSINESS_GROUP_ID RECRUITER_ID GRADE_ID POSITION_ID JOB_ID ASSIGNMENT_STATUS_TYPE_ID PAYROLL_ID LOCATION_ID PERSON_REFERRED_BY_ID SUPERVISOR_ID SPECIAL_CEILING_STEP_ID PERSON_ID RECRUITMENT_ACTIVITY_ID SOURCE_ORGANIZATION_ID ORGANIZATION_ID PEOPLE_GROUP_ID SOFT_CODING_KEYFLEX_ID VACANCY_ID PAY_BASIS_ID ASSIGNMENT_SEQUENCE ASSIGNMENT_TYPE PRIMARY_FLAG APPLICATION_ID ASSIGNMENT_NUMBER CHANGE_REASON COMMENT_ID DATE_PROBATION_END DEFAULT_CODE_COMB_ID EMPLOYMENT_CATEGORY FREQUENCY INTERNAL_ADDRESS_LINE MANAGER_FLAG NORMAL_HOURS PERF_REVIEW_PERIOD PERF_REVIEW_PERIOD_FREQUENCY PERIOD_OF_SERVICE_ID PROBATION_PERIOD PROBATION_UNIT SAL_REVIEW_PERIOD SAL_REVIEW_PERIOD_FREQUENCY SET_OF_BOOKS_ID SOURCE_TYPE TIME_NORMAL_FINISH TIME_NORMAL_START BARGAINING_UNIT_CODE LABOUR_UNION_MEMBER_FLAG HOURLY_SALARIED_CODE REQUEST_ID PROGRAM_APPLICATION_ID PROGRAM_ID PROGRAM_UPDATE_DATE ASS_ATTRIBUTE_CATEGORY ASS_ATTRIBUTE1 ASS_ATTRIBUTE2 ASS_ATTRIBUTE3 ASS_ATTRIBUTE4 ASS_ATTRIBUTE5 ASS_ATTRIBUTE6 ASS_ATTRIBUTE7 ASS_ATTRIBUTE8 ASS_ATTRIBUTE9 ASS_ATTRIBUTE10 ASS_ATTRIBUTE11 ASS_ATTRIBUTE12 ASS_ATTRIBUTE13 ASS_ATTRIBUTE14 ASS_ATTRIBUTE15 ASS_ATTRIBUTE16 ASS_ATTRIBUTE17 ASS_ATTRIBUTE18 ASS_ATTRIBUTE19 ASS_ATTRIBUTE20 ASS_ATTRIBUTE21 ASS_ATTRIBUTE22 ASS_ATTRIBUTE23 ASS_ATTRIBUTE24 ASS_ATTRIBUTE25 ASS_ATTRIBUTE26 ASS_ATTRIBUTE27 ASS_ATTRIBUTE28 ASS_ATTRIBUTE29 ASS_ATTRIBUTE30 LAST_UPDATE_DATE LAST_UPDATED_BY LAST_UPDATE_LOGIN CREATED_BY CREATION_DATE TITLE OBJECT_VERSION_NUMBER
931510 7-Nov-08 31-Dec-12 122 (null) (null) (null) 3978 1 (null) 14402 (null) 220150 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 2 E Y (null) 100035417-2 (null) (null) (null) 45948739 (null) (null) (null) (null) (null) (null) (null) 868007 (null) (null) (null) (null) 449 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 26-Aug-08 26-Aug-08 122 (null) (null) (null) 3980 3 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
916076 26-Aug-08 31-Dec-12 122 (null) (null) (null) 3980 1 4 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 B Y (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 25-Feb-08 25-Aug-08 122 (null) (null) (null) 3980 1 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
Maybe you are looking for
-
HELP: Cannot restore DMG image stored on NTFS disk!
Hello. My MacBook Pro has OSX Lion on it. I have created a DMG image of my starting volume using Disk Utility. The image was saved on an NTFS formatted external USB disk. I used Paragon NTFS for Mac to activate writing on NTFS partitions. The image w
-
Problem with marking mail as Not Junk in IMAP account
Hi, I have an IMAP email account on Go Daddy that I forward all my other mail accounts for processing. I use Apple Mail to process this IMAP account and use Mail.app's Junk filter to move Junk mail to the Junk mailbox. This Junk mailbox is mapped in
-
How do I get the printer to work with AirPort?
I have had my printer connected via USB cable to the AirPort for a while, but recently when I had to disconnect the printer for some home improvement, I ended up with problems. Upon reconnecting the printer to the AirPort, I started receiving this me
-
I had previously had an iphone5 but it got stolen and I just got the iphone5s. I had previously backed up my old iphone to my itunes, and didnt have time to restore it to my new phone. I had taken pictures with my new iphone and when i connected it t
-
JScrollPane: Can the Vertical Scroll Bar go on the left?
Hope you can help, Im using a JScrollPane within another one, i.e, I have a component inside a JScrollPane, and one of its components is a JScrollPane. This is fine and dandy, but the internal scrolled component gets pretty tall and wide, so people e