SQLTeam.com | Weblogs | Forums

Parameter help


#1

Hi all,

Below are my dataset from my simple select statement:

select count(position) as CNT, Balls, Position, Players
from Soccerdatabase

CNT BALLS POSITION PLAYERS
2 A Middle Blue
5 C front Red
1 E Middle Yellow
4 F Middle Purple
6 K front Orange
3 B Middle Brown
1 G front Green

How do I update above query so users can display the report with a parameter to select POSITION for more than 2, 3 or 4, etc?
For example: A user just want to see a report where the POSITION is "Middle" and the count is more than 2? Or POSITION is "front" and the count is more than 1?

Anyone?


#2
SELECT count(position) AS CNT,
	Balls,
	Position,
	Players
FROM Soccerdatabase
WHERE Position = @Position
GROUP BY Balls,
	Position,
	Players
HAVING count(position) >= @count

#3

You are smart Khtan