Oracle query question

Results 1 to 3 of 3

Thread: Oracle query question

  1. #1
    Join Date
    Dec 1969

    Default Oracle query question

    Let&#039;s say i have a following table containing following cols:<BR>ARTICLE_ID, PRICE. (Oracle 7.3)<BR><BR>The same article_id can occur several times, with the same or different PRICE.<BR>I need to select the TOP xx ARTICLE_ID:s which are the most occuring articles.<BR><BR>So if ARTICLE_ID "1234-5" occurs 9 times in the table, and "1234-6" occurs 7<BR>times etc etc i want the output as follows:<BR><BR>ARTICLE_ID OCCURED_NO_OF_TIMES<BR>1234-5 9<BR>1234-6 7<BR>...etc,etc...<BR><BR>Any code or references are appreciated.<BR><BR>Thanks<BR>..a

  2. #2
    Smayle Guest

    Default RE: Oracle query question

    Maybe do...<BR><BR>Select article_id, count(article_id) from your_tablename group by article_id<BR><BR>this should group and count so you only see the article_id with the count next to it.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: thanks

    Thanks! Below code gave me the a sorted result based on most occuring article...<BR><BR>select part_no, count(part_no) as num from mytable group by part_no order by num DESC<BR><BR>..a

Posting Permissions

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