Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
help; a challenging SQL request
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
charles  
View profile  
 More options Jun 29 2011, 11:08 am
Newsgroups: comp.databases.oracle.server
From: charles <dshprope...@gmail.com>
Date: Wed, 29 Jun 2011 08:08:32 -0700 (PDT)
Local: Wed, Jun 29 2011 11:08 am
Subject: help; a challenging SQL request
Group,

I need to write a SQL which find all the match recording for a
particular person

For example
COL1               COL2
john                 a
john                 b
john                 c
joe                  a
joe                  c
tim                  a
tim                  b
tim                  c

I would like to find all the person who has the same entry as john (a,
b,c ),  which tim is.

How should i build that SQL?

Thanks for your help


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Klemme  
View profile  
 More options Jun 29 2011, 12:36 pm
Newsgroups: comp.databases.oracle.server
From: Robert Klemme <shortcut...@googlemail.com>
Date: Wed, 29 Jun 2011 18:36:01 +0200
Local: Wed, Jun 29 2011 12:36 pm
Subject: Re: help; a challenging SQL request
On 29.06.2011 17:08, charles wrote:

It seems you do not read replies you get.  And why do you open a new thread?

Cheers

        robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Walt  
View profile  
 More options Jun 30 2011, 3:19 pm
Newsgroups: comp.databases.oracle.server
From: Walt <walt_ask...@yahoo.com>
Date: Thu, 30 Jun 2011 15:19:20 -0400
Local: Thurs, Jun 30 2011 3:19 pm
Subject: Re: help; a challenging SQL request
On 6/30/2011 6:41 AM, Preston wrote:

> Robert Klemme wrote:

>> On 29.06.2011 17:08, charles wrote:
>>> Group,

>>> I need to write a SQL which find all the match recording for a
>>> particular person

>> It seems you do not read replies you get.  And why do you open a new
>> thread?

> He's using Google Groups which has been broken for the last few days.
> It's not showing any usenet posts since the 27th. So he won't see
> either his original post, or any replies (including these).

I almost didn't reply to this since it appears to be a homework problem,
but the simplest way to solve it is to use the following PL/SQL function
and compare the concatenated 2nd column values.

CREATE OR REPLACE FUNCTION Concatenate_List (p_cursor IN  SYS_REFCURSOR,
delimiter IN VARCHAR2)
  RETURN  CLOB
IS
  l_return  VARCHAR2(32767);
  l_temp    VARCHAR2(32767);
BEGIN
  /* This function executes the passed query and creates a string of all the
  returned values, separated by the passed delimiter.
  This is one solution of many to allow one to aggregate multiple values
  from a correlated subquery into a string.  See here for more info:
  http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
   */
  LOOP
    FETCH p_cursor
    INTO  l_temp;
    EXIT WHEN p_cursor%NOTFOUND;
    IF l_return IS NOT NULL THEN
        l_return := l_return || delimiter;
    END IF;
    l_return := l_return || l_temp;
  END LOOP;
  CLOSE p_cursor;
  RETURN l_return;
END;
/

//Walt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
charles  
View profile  
 More options Jul 1 2011, 9:17 am
Newsgroups: comp.databases.oracle.server
From: charles <dshprope...@gmail.com>
Date: Fri, 1 Jul 2011 06:17:25 -0700 (PDT)
Local: Fri, Jul 1 2011 9:17 am
Subject: Re: help; a challenging SQL request

> He's using Google Groups which has been broken for the last few days.
> It's not showing any usenet posts since the 27th. So he won't see
> either his original post, or any replies (including these).

> --
> Preston.

Thanks Preston for explain to me.  I did not see my postings, thought
my messages did not go through.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jsfromynr  
View profile  
 More options Jul 4 2011, 2:33 am
Newsgroups: comp.databases.oracle.server
From: jsfromynr <jatinder.1...@gmail.com>
Date: Sun, 3 Jul 2011 23:33:39 -0700 (PDT)
Local: Mon, Jul 4 2011 2:33 am
Subject: Re: help; a challenging SQL request
On Jul 1, 6:17 pm, charles <dshprope...@gmail.com> wrote:

> > He's using Google Groups which has been broken for the last few days.
> > It's not showing any usenet posts since the 27th. So he won't see
> > either his original post, or any replies (including these).

> > --
> > Preston.

> Thanks Preston for explain to me.  I did not see my postings, thought
> my messages did not go through.

Hello There,

See if this helps.

Select t2.Col1  from tmp_data t1
Inner Join tmp_data t2 on t1.Col2=t2.Col2
And t1.Col1='john' and t2.Col1!='john'
group by t2.Col1
having COUNT(distinct t2.Col2) =
(
Select count(distinct Col2) from tmp_data Where Col1='john'
)

With Warm regards
Jatinder Singh
http://jatindersingh.blogspot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »