Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

any body send me select statement

naveen_inuganti2
Active Contributor
0 Kudos

Hi all.

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

thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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