05-19-2008 1:50 PM
Hi all.
Any body send me one select statement with sum and other one with count.
thank you.
05-19-2008 3: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.
05-19-2008 1: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
05-19-2008 3: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
05-19-2008 3: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.
05-19-2008 3: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