Topic
5 replies Latest Post - ‏2013-05-15T04:57:04Z by NFE6_Tomasz_Brychcy
NFE6_Tomasz_Brychcy
NFE6_Tomasz_Brychcy
3 Posts
ACCEPTED ANSWER

Pinned topic A query to get information from a table

‏2013-05-07T11:22:39Z |

Hello,

I need a help to retrieve specific information from table. The table is named X and stores transactions. Each transaction id_trans corresponds to the id_customer. One id_customer might have 1 transaction logged, next id_customer might have 4 transactions logged and so on. The task is to display a table with two columns Number_of_trans and Number_of_id_customer. The output should display:

Number_of_trans Number_of_id_customer
1 134
2 75
.. ..
n n_customers

Any help would be very appreciated. Thank you in advance.

BR,

TB

  • Sreeharsha_Naik
    Sreeharsha_Naik
    6 Posts
    ACCEPTED ANSWER

    Re: A query to get information from a table

    ‏2013-05-09T19:53:43Z  in response to NFE6_Tomasz_Brychcy

    Hello,

    If I have understood your requirement right - all you need is a different column name to be displayed in your result table ? Is that correct ? I am assuming the records in your table X gets populated through some source and there is no logic needed for populating that data ?

    Regards,
    Sreeharsha
     


     

  • LukeNumrych
    LukeNumrych
    47 Posts
    ACCEPTED ANSWER

    Re: A query to get information from a table

    ‏2013-05-09T20:02:45Z  in response to NFE6_Tomasz_Brychcy

     

    Something like this?

    select count(
    id_trans), 
    id_customer from 
    tablename group by 
    id_customer order by count(
    id_trans)
    ;
    

     

     

    This assumes that you have no rows where id_customer or id_trans are null.  The code would need to be changed depending on how you do you want to treat these cases.

    Updated on 2013-05-09T20:08:11Z at 2013-05-09T20:08:11Z by LukeNumrych
  • NFE6_Tomasz_Brychcy
    NFE6_Tomasz_Brychcy
    3 Posts
    ACCEPTED ANSWER

    Re: A query to get information from a table

    ‏2013-05-14T05:40:23Z  in response to NFE6_Tomasz_Brychcy

    Thank you all of you for your interest and help. I apologize for a delay with providing the feedback.

    Your (LukeNumrych) assistance (with a little bit modify) gave me exactly the solution I expected :-). 

    BR,

    TB