Re: Basic SQL



"Stefan Rybacki" <stefan.rybacki@xxxxxxx> wrote in message news:3jlhr8Fqd4cmU2@xxxxxxxxxxxxxxxxx
> John Gilson wrote:
> > "MS" <mesemailoffers@xxxxxxxxxxx> wrote in message
> > news:1121280375.735695.277470@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >
> >>I am trying to write a sql statement that gives me the records that
> >>have multiple values for column b, but cannot figure it out - can
> >>someone help?
> >>
> >>My table is as follows:
> >>
> >>ID Value
> >>1234 S
> >>1234 S
> >>1234 X
> >>4444 S
> >>5555 X
> >>5555 Y
> >>
> >>I want to see what records have two distinct values for the "Value"
> >>column. The results of the query when running against the above data
> >>should be as follows:
> >>
> >>ID Value
> >>1234 S
> >>1234 X
> >>5555 Y
> >>5555 X
> >>
> >>Any help would be appreciated.
> >>
> >>Thanks!
> >
> >
> > SELECT ID, Value
> > FROM (SELECT DISTINCT id, value FROM T) AS T
> > WHERE EXISTS (SELECT * FROM T AS T1
> > WHERE T1.ID = T.ID AND
> > T1.Value <> T.Value)
> >
> > --
> > JAG
> >
> >
> Ui two subselects? :/ I even don't like the one I used in my solution ;)
>
> Regards
> Stefan

Given the original poster's stated input and required output, your query doesn't
do the trick.

--
JAG


.



Relevant Pages

  • Re: Sessions and Pagination Problem
    ... I don't get an error with the query. ... I have multiple if statements that append "AND"'s to the SQL statement ... If you click on page numbers and the prev or next links, ...
    (comp.lang.php)
  • Re: query wont return results
    ... Following is the SQL statement of my query ... FROM (tblCourses INNER JOIN tblHoles ON tblCourses.CourseID = ... Post the SQL statement of it. ... Prev by Date: ...
    (microsoft.public.access.queries)
  • Re: How do update data more convient?
    ... Why not use Stored procedures.Its a simple SQL statement. ... be used when your query is really really on fly, ... My Interview Blog ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: When do I open my Recordsets?
    ... > So if I build an SQL statement using parameters in the query SQL View, ... > I call the query, then I don't have to worry about what I am doing in the ... Prev by Date: ...
    (microsoft.public.access.formscoding)
  • Basic SQL
    ... I am trying to write a sql statement that gives me the records that ... have multiple values for column b, but cannot figure it out - can ... The results of the query when running against the above data ... Prev by Date: ...
    (comp.databases)