Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use sql view for count and sum

Status
Not open for further replies.

DebbieDavis

Programmer
Jun 7, 2002
146
0
0
US
Hi there,

I'm sure this is an elementary question but I'm not as SQL proficient as I'd like to be. I have a view with two tables to display data from on my page. Do I have to create a recordset for each task if I need a count and a sum of different things in the view, i.e. there are registrants that have paid full price, registrants that have discounts and registrants that are comp, and I need a count and a sum for each of those groups. Do I have to create three separate recordsets? I do not know how to do stored procedures. Can this be done in one stored procedure? Thanks for your input.
 
Hi
you only have to create a single recordset using a group by query. Here is an example you can run on a SQL server it uses the pubs sample database

select j.job_desc , count(e.emp_id) AS NoOfEmployees
from employee e
inner join jobs j on e.job_id=j.job_id
group by j.job_desc

this query will display how many employees are there for each job title. I think what you need is something like this

HTH

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top