Query question

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

    #1

    Query question

    Hi, I have the following query:

    select sls2.shpr, sum(sls2.pkgs) as pkgs, sum(sls2.amnt) as sales,
    nams.code, nams.name, sls1.numb, sls2.numb, sls1.prnt
    from sls1, sls2, nams
    where sls2.shpr=nams. code and sls1.numb=sls2. numb and sls1.prnt=2
    group by sls2.shpr
    order by sales desc

    This gives me a ranking of our suppliers. I want to modify it though.

    There is another field (char(4)) in the sls2 table called comm. If the
    first character in this field is a 'W', I want to exclude that record from
    the sum of sls2.amnt. And if it's an 'L' I want to exclude that record
    from the sum of sls2.pkgs

    I'm using MySQL 4.1.


    Can anyone provide a clue? Thanks.


Working...