Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Please help

Author  Topic 

jbnapoko
Starting Member

1 Post

Posted - 2012-05-08 : 18:35:13
i have this sql which is incomplete... i need to sum what count has brought in subtotal so as to get 6. the sql is;

mysql> select curiosity, count(*) as subtotal from std_eva where lect_id="L3435" group by curiosity;
+-----------+----------+
| curiosity | subtotal |
+-----------+----------+
| 1 | 2 |
| 2 | 2 |
| 5 | 2 |
+-----------+----------+
3 rows in set (0.00 sec)

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-08 : 18:47:14
[code]

select sum(subtotal ) Total from
(select curiosity, count(*) as subtotal from std_eva where lect_id="L3435" group by curiosity) Tab[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-08 : 19:59:26
this is not mysql forum. so you may be better off posting this in relevant forums if above suggestion doesnt work. this is ms sql server forum

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

vinu.vijayan
Posting Yak Master

227 Posts

Posted - 2012-05-09 : 06:42:35
quote:
Originally posted by vijays3



select sum(subtotal ) Total from
(select curiosity, count(*) as subtotal from std_eva where lect_id="L3435" group by curiosity) Tab




vijays3's solution should work if you are using MSSQL. If you are using MYSQL then try posting here:

[url]http://forums.mysql.com/[/url]

N 28° 33' 11.93148"
E 77° 14' 33.66384"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-05-10 : 08:40:39
quote:
Originally posted by vinu.vijayan

quote:
Originally posted by vijays3



select sum(subtotal ) Total from
(select curiosity, count(*) as subtotal from std_eva where lect_id="L3435" group by curiosity) Tab




vijays3's solution should work if you are using MSSQL. If you are using MYSQL then try posting here:

[url]http://forums.mysql.com/[/url]

N 28° 33' 11.93148"
E 77° 14' 33.66384"


It will also work Mysql too

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -