Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2006
    Posts
    38

    Unanswered: The two query equals?

    hi,In MySql,we can run below query
    Code:
    select appid,dvbpath,business from ocgxmldbinfo group by appid
    but in MSSql,it can't!so i want to know whether the following query equals it?
    Code:
    select distinct appid,dvbpath,business from ocgxmldbinfo order by appid
    thanks!

  2. #2
    Join Date
    May 2005
    Posts
    33
    no
    try this:
    select appid,min(dvbpath),min(business) from ocgxmldbinfo group by appid

  3. #3
    Join Date
    Feb 2006
    Posts
    38
    Quote Originally Posted by AmitGeorge
    no
    try this:
    select appid,min(dvbpath),min(business) from ocgxmldbinfo group by appid
    I try it,the result is right,can you explain this query?why it equals
    Code:
    select appid,dvbpath,business from ocgxmldbinfo group by appid

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the result is not right

    i can explain it easily -- mysql will quite happily run invalid syntax

    read this entire page: 12.10.3 GROUP BY with Hidden Fields
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2006
    Posts
    38
    Quote Originally Posted by r937
    the result is not right

    i can explain it easily -- mysql will quite happily run invalid syntax

    read this entire page: 12.10.3 GROUP BY with Hidden Fields
    well,can you tell me in mssql the below query equals what?
    Code:
    select appid,dvbpath,business from ocgxmldbinfo group by appid

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that query doesn't have an equivalent in microsoft sql server because it's invalid
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Feb 2006
    Posts
    38
    thank you very much!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •