Skip to Content

any body send me select statement

Hi all.

Any body send me one select statement with sum and other one with count.

thank you.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 19, 2008 at 02:13 PM

    HI,

    count

    TABLES SPFLI.
    DATA   COUNT TYPE I.
    
    SELECT COUNT( DISTINCT CARRID )
           INTO COUNT FROM SPFLI
           WHERE
             CITYTO = 'NEW YORK'.
    WRITE: / COUNT.
    

    sum

    TABLES SBOOK.
    DATA:  SUM TYPE P DECIMALS 2.
    DATA:  CONNID LIKE SBOOK-CONNID.
    
    SELECT SUM( LUGGWEIGHT )
           INTO SUM
           FROM SBOOK
           WHERE
             CARRID   = 'LH '
           GROUP BY CONNID.
      WRITE: / SUM.
    ENDSELECT.
    

    rgds,

    bharat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2008 at 12:53 PM

    here u go

    SELECT AVG( luggweight ) AS average SUM( luggweight ) AS sum

    INTO CORRESPONDING FIELDS OF luggage

    FROM sbook.

    count

    select count * from vbap into l_count

    where vbeln = l_vbeln

    regards,

    Advait

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2008 at 02:02 PM

    SELECT t1.dept_id, t1.dept_name, t2.staff

    FROM zdept t1, (SELECT dept_id,

    COUNT(*) AS STAFF

    FROM zemp

    ) t2

    WHERE t1.dept_id = t2.dept_id

    AND t2.staff >= 3;

    SELECT SUM(sal) INTO itab FROM zempl

    WHERE dep_id in s_depid

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2008 at 02:15 PM

    Hi Naveen Inuganti ,

    Check the following statements.

    tables scustom.
    data row_count type i.
    select count(*) from scustom into row_count.
    write: / 'The SCUSTOM table has', row_count, 'rows'.

    Calculates the number of rows in a table and puts the total into a data object.

    tables sbook. 
    data: count type i, 
          sum type p decimals 2, 
          avg like sum,
          connid like sbook-connid. 
    select connid count(*) sum( luggweight ) avg( luggweight ) 
    	into (connid, count, sum, avg) 
    	from sbook 
    	where carrid = 'LH' and fldate = '20010228' 
    	group by connid. 
      write: / connid, count, sum, avg. 
    endselect.

    Outputs the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.2001

    Hope its useful.

    Reward points if useful.

    Thanks ,

    Surya Pydikondala

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.