Database

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted
##
##### Forming Groups which are circular in nature

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

07-31-2013
06:49 PM

07-31-2013
06:49 PM

Hi All,

I have data as below from which I should form the groups:

Input:-

Table1:-

Parent_Char - Child_Char

A - B

X - Y

B - C

Y - X

C - A

M - N

N - M

Table2:-

Char - Value

A - 100

X - 600

Y - 40

N - 500

M - 100

B - 60

C - 50

Z - 40

I should form the groups using Table 1 and decide Group ID using Table 2.

The logic should be as below:-

Start from Parent_Char (i.e. A) and get the Child_Char (i.e. B), use this Child_Char as Parent_Char to get next Child_Char (i.e. C), use this Child_Char as Parent_Char to get the next Child_Char (i.e. A) and so on.

Repeat this process till we arrive the starting Parent (i.e. A).

Hence, the groups will be as below:-

A ---> B ---> C ---> A

X ---> Y ---> X

M ---> N ---> M

Take the highest value in Table 2 as Group ID.

Expected Output is :-

Group ID - Member

A - A

A - B

A - C

X - X

X - Y

N - N

N - M

Please advise.

Thanks a lot in advance.

Sagar

3 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-01-2013
01:52 AM

08-01-2013
01:52 AM

Hi Sagar,

how do you know that A is the starting point and not B or C?

A ---> B ---> C ---> A

B ---> C ---> A ---> B

C ---> A ---> B ---> C

Dieter

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-09-2013
01:12 AM

08-09-2013
01:12 AM

Hi Dieter,

Based on some business conditions the starting point can be decided.

In this case, assuming starting point as A to check further.

Sagar.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-09-2013
02:04 AM

08-09-2013
02:04 AM

Hi Sagar,

for me assumimg is easy, but it's hard for SQL :-)

There must be a SQL-condition to find the starting point.

Dieter