Results 1 to 5 of 5

Thread: Help with SQL queries?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Location
    Propped up at a PC near you...
    Posts
    194

    Help with SQL queries?

    I am DESPERATE for help with an sql query, does anyone know of a good forum?

  2. #2
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Try checking out Beacons thread...
    ** HOLLY **

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Well, depending on your problem, this is a good place to start, or you can try http://dbforums.com or I've heard that http://www.sql-server-performance.com is pretty good too (I haven't visited it yet).

    What's the prob?
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Location
    Propped up at a PC near you...
    Posts
    194
    Im stuck on this question (It's homework, so I would like DIRECTION not the answer)

    'For any given part, give the details of the supplier with the cheapest purchase price. The user should be prompted to enter the supplier number on the screen.'

    I've been trying various combinations similar to this:

    <SQL> SELECT MIN(Price) AS LowestPrice, SUP_NAME, SUP_TOWN, SUP_COUNTY
    2 FROM MMSuppliers s, MMParts p;
    SELECT MIN(Price) AS LowestPrice, SUP_NAME, SUP_TOWN, SUP_COUNTY</SQL>
    *
    ERROR at line 1:
    ORA-00937: not a single-group group function

    Any Ideas how to point me in the right direction.
    P.s I'm a newbie, so please don't get all technical on me

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Well, the problem is the SELECT statement.
    In as simple terms as I can, the problem is this: When you use an aggregate function, such as MIN, MAX, SUM, AVG, (and there are more), you have to do a GROUP BY, and then tell it what fields to group on. Usually, this would be all of your other non-aggregated fields.
    Here's an example. Let's say I have a table, for simplicity, three fields: PriceID, PriceValue, and PriceName.
    The table looks like this:
    Code:
    1     SomePrice      2.00
    1     SomePrice      5.50
    1     SomePrice      5.95
    1     SomePrice      5.00
    3     AnotherPrice  2.50
    3     AnotherPrice  3.00
    4     DifferentPrice 1.25
    4     DifferentPrice 0.25
    4     DifferentPrice 0.29
    4     DifferentPrice 0.95
    5     OldPrice         4.30
    5     OldPrice         4.95
    5     OldPrice         4.15
    If I wanted to find the lowest price, I can do SELECT MIN(PriceValue) FROM tblPrice. That will give me the smallest value of PriceValue. I would get the result: 0.25
    But, let's say that I want to find the lowest price for each price. It would look like this: SELECT PriceID, PriceName, MIN(PriceValue) FROM tblPrice GROUP BY PriceID, PriceName.
    I would get something that should look like:
    Code:
    1     SomePrice      5.00
    3     AnotherPrice  2.50
    4     DifferentPrice 0.25
    5     OldPrice         4.15
    Hope this helps some.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

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



Click Here to Expand Forum to Full Width