本文介绍了如何使用datalist控件计算记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有三个表,如tblStates(StateId,StateName),tblCities(StateName,Id,CityName)& tblPost(Id,StateName,CityName,AdTitle,description)。现在,我想计算个别国家/地区发布的广告数量。使用任何绑定控件的城市。



Ex:预期输出为



Andhra Pradesh(20)

---------------

Vijayawada(5)

Guntur(5)

维萨卡帕特南(3)

蒂鲁帕蒂(5)

卡达帕(2)



卡纳塔克邦(20) )

-----------

班加罗尔(5)

芒格洛尔(5)

迈索尔(5)

比利时(5)



Tamilnadu(20)

---- -----

金奈(10)

Coimbator(5)

Selum(3)

Hosur (2)



等..



注意: StateName& CityName我们可以从tblStates&只有tblCities和count应该从tblPost表绑定。



提前谢谢。

Dear Friends,

I have three tables like tblStates(StateId, StateName) , tblCities (StateName, Id, CityName) & tblPost(Id, StateName, CityName, AdTitle, description). Now I would like to count the no.of ads posted in individual States & Cities using any bound Control.

Ex: Expected output is

Andhra Pradesh (20)
---------------
Vijayawada (5)
Guntur (5)
Visakapatnam (3)
Tirupati (5)
Kadapa (2)

Karnataka (20)
-----------
Bangalore (5)
Mangalore (5)
Mysore (5)
Belgum (5)

Tamilnadu (20)
---------
Chennai (10)
Coimbator (5)
Selum (3)
Hosur (2)

etc..

Note: StateName & CityName we can bind from tblStates & tblCities only and the count should be bind from tblPost table.

Thanks in advance.

推荐答案

SELECT s.StateName,
       (   SELECT COUNT(*)
           FROM   tblCities c
           WHERE  c.StateName = s.StateName)
FROM   tblStates s



使用相同的想法我相信很容易计算广告。


Using the same idea I believe it would be easy to count the ads.


这篇关于如何使用datalist控件计算记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 18:44