SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2003
    Location
    los angeles
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Difficult SQL Query

    Hello, have a difficult query to write. It goes something like this:

    SELECT a, b, (SELECT COUNT(*) FROM table2 WHERE x = a) as c

    FROM table1

    ORDER BY (a * c)


    I've actually simplified this a bit, but hopefully it makes sense? Is this doable?

  2. #2
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT a, b, COUNT(x) as c
    FROM table1, table2
    WHERE x = a
    GROUP BY a, b
    ORDER BY (a * COUNT(x))


Bookmarks

Posting Permissions

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