Try

SQL

select sum(Hocount) + sum(seats) as total from handout h inner join stockentry s on h.type= s.type and h.course = s.course where h.type= 'H' and h.course = 'AFF'

See more:

SQL

select sum(Hocount) as total from handout where type= 'H' and course = 'AFF'

Output as follows

Total

150

SQL

select sum(seats) as total from stockentry where where type= 'H' and course = 'AFF'

Output as follows

Total

100

Using combining above two sql query i want the output as follows in single query.

Total

250

for that how can i write the sql query to get the output in single sql query.

Regards,

Narasiman P.

Just an idea:

Try

Try

SQL

select sum(Hocount) + sum(seats) as total from handout h inner join stockentry s on h.type= s.type and h.course = s.course where h.type= 'H' and h.course = 'AFF'

Permalink

Share this answer

Try this

select sum(x.total) as Total from ( select sum(Hocount) as total from handout where type= 'H' and course = 'AFF' union select sum(seats) as total from stockentry where where type= 'H' and course = 'AFF' )x

Permalink

Share this answer

Try:

SQL

SELECT (select sum(Hocount) as total from handout where type= 'H' and course = 'AFF') + (select sum(seats) as total from stockentry where where type= 'H' and course = 'AFF')

Permalink

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900