• As you have found out, SQL is not at its best presenting data to the world. That is usually the job of the front end!

    I was not 100% sure what you are trying to count so I took a stab at it.

    select d.doctorname, d.location, dg.name, dg.packsize,

    ROW_NUMBER() over(partition by d.doctorname order by (select 0)) Total_Drugs

    from Doctor_Prescribed_Drugs dpd

    left join Doctor d on dpd.doctorref = d.doctorref

    left join drugs dg on dpd.drugref = dg.drugref

    where d.Location in ('London', 'Manchester') and dg.PackSize is not null

    group by d.doctorname, d.location, dg.name, dg.PackSize

    order by d.doctorname, Total_Drugs

    I just added a Row_Number based on the doctorname. That effectively gives you a running count of drugs prescribed by each doctor.

    HTH

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/