SQL Query help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KinRsole

    #1

    SQL Query help

    Hi
    I need to write some queries for a collage assignment but I am really
    struggling.I am very new to any form of SQL.

    I have the following tables. Sorry about the formatting.
    +-----+-------------+------------------+---------+--------+------------+
    | CNO | CNAME | STREET | TOWN | BROKER | DOJ |
    +-----+-------------+------------------+---------+--------+------------+
    | 1 | CARTER | 10 BARNABY COAST | BBURN | 1 | 1988-03-01 |
    | 2 | HOLDSWORTH | 15 SNOB HILL | BBURN | 3 | 1992-08-01 |
    | 3 | GT PENS FND | 10 HIGH STREET | BBURN | NULL | 1993-06-17 |
    | 4 | INVEST INC | 18 PALL MALL | CHORLEY | 1 | 1992-01-02 |
    | 5 | WILSON | 12 GRAND MALL | CHORLEY | 1 | 1985-04-01 |
    | 6 | AINSWORTH | 18 GRAND MALL | CHORLEY | 2 | 1985-03-01 |
    | 7 | YUPPIES INC | 305 KINGSWAY | LONDON | NULL | 1991-06-17 |
    +-----+-------------+------------------+---------+--------+------------+
    7 rows in set (0.35 sec)

    mysql> select * from holding;
    +------+----------------+------------+------+------------+
    | CNO | SNAME | TDATE | QTY | PURCHPRICE |
    +------+----------------+------------+------+------------+
    | 1 | MIRROR GROUP | 1994-05-01 | 200 | 160 |
    | 1 | ARAN ENERGY | 1994-05-01 | 1000 | 24 |
    | 1 | EURODISNEY | 1994-05-01 | 500 | 160 |
    | 2 | OWNERS ABROAD | 1994-05-04 | 500 | 90 |
    | 1 | CARLTON COMM | 1994-05-04 | 1000 | 1000 |
    | 3 | SLEEPY KIDS | 1994-05-04 | 800 | 150 |
    | 2 | MIDLAND | 1994-05-05 | 400 | 152 |
    | 4 | ROYAL DUTCH | 1994-05-06 | 300 | 6500 |
    | 4 | MIDLAND | 1994-05-06 | 200 | 155 |
    | 2 | WHITBREAD | 1994-05-07 | 500 | 500 |
    | 2 | BRITISH PETROL | 1994-05-07 | 400 | 380 |
    | 2 | WHITBREAD | 1994-05-11 | 200 | 510 |
    | 3 | CARLTON COMM | 1994-05-12 | 1000 | 900 |
    | 2 | AIRTOURS | 1994-05-14 | 500 | 520 |
    +------+----------------+------------+------+------------+
    14 rows in set (0.04 sec)

    mysql> select * from shares
    -> ;
    +----------------+------------+--------+------+------+
    | SNAME | SCAT | CPRICE | LOW | HIGH |
    +----------------+------------+--------+------+------+
    | MIDLAND | MEDIA | 164 | 152 | 177 |
    | CARLTON COMM | MEDIA | 884 | 797 | 1025 |
    | MIRROR GROUP | MEDIA | 152 | 123 | 201 |
    | SLEEPY KIDS | MEDIA | 66 | 64 | 67 |
    | ARAN ENERGY | OILS | 32 | 24 | 33 |
    | BRITISH PETROL | OILS | 400 | 349 | 411 |
    | ROYAL DUTCH | OILS | 6600 | 6500 | 7437 |
    | AIRTOURS | LEIS/HOTEL | 463 | 418 | 553 |
    | EURODISNEY | LEIS/HOTEL | 124 | 119 | 195 |
    | N LEIS | LEIS/HOTEL | 50 | 40 | 57 |
    | OWNERS ABROAD | LEIS/HOTEL | 103 | 89 | 129 |
    | BODDINGTONS | BREWERIES | 265 | 250 | 295 |
    | WHITBREAD | BREWERIES | 541 | 496 | 614 |
    +----------------+------------+--------+------+------+
    13 rows in set (0.04 sec)

    mysql> select * from broker;
    +-----+---------+------------+----------+
    | BNO | BNAME | BTOWN | COMMRATE |
    +-----+---------+------------+----------+
    | 1 | ABC LTD | CHORLEY | 10 |
    | 2 | XYZ LTD | OSWTWISTLE | 8 |
    | 3 | WHITES | BBURN | 12 |
    +-----+---------+------------+----------+
    3 rows in set (0.06 sec)

    From these I need to answer 15 questions. I have managed the first 4 but
    can't seem to get any further.

    the first one I'm stuck on is to do with null values.
    I need to list the client names & broker names for all clients including
    those who do not have a broker.
    I have using the IFNULL but with no success.
    Could somebody please help me out?
    cheers

    Kin


  • Steve

    #2
    Re: SQL Query help

    Ask your professor for help.

    ---
    Steve

    Comment

    • KinRsole

      #3
      Re: SQL Query help

      cheers for that

      "Steve" <googlespam@nas tysoft.com> wrote in message
      news:1106232145 .759930.148430@ z14g2000cwz.goo glegroups.com.. .[color=blue]
      > Ask your professor for help.
      >
      > ---
      > Steve
      >[/color]


      Comment

      Working...