Good Day All

i have the Following that table

ID  | ACTV |VENU |STUD | TRIES
=====================================
1	1   4	 162	     0
2	4   5	 104	     0
3	8   5	 138	     0
4	15  2	 68	     0
5	15  4	 291	     0
6	21  4	 171	     0
7	22  5	 101	     0
8	27  4	 11	     0
9	28  5	 6	     0
10	31  4	 8	     0
11	32  6	 6	     0 
12	33  4	 308	     0
13	35  6	 68	     0

now i have the Following Query that Tries to find the ID's of the records that appear twice in the "VENU" Field.

SELECT id 
FROM [dbo].SOL_ACTV_VENU
group by  id 
having count(venu) > 1
order by sum(stud)

and it seems that it give me nothing while in the table i see there are records like that

Thanks

group by venu

group by venu

i get this

Msg 8120, Level 16, State 1, Line 2
Column 'dbo.SOL_ACTV_VENU.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

and i will try to add it in the select and it will still give me nothing

change select venu from......

Exactly what do you want.
for example for venu 6 you have two id (11,13), for venu 2 who have only one id (4) .
Now tell me what you want to display.

change select venu from......

Exactly what do you want.
for example for venu 6 you have two id (11,13), for venu 2 who have only one id (4) .
Now tell me what you want to display.

Thanks For your answer. i want display 11,13 only not two because it appears once.

Thanks

SELECT id ,venu
FROM [dbo].SOL_ACTV_VENU
where venu in (select venu from FROM [dbo].SOL_ACTV_VENU
group by  venu 
having count(venu) > 1
order by sum(stud)

)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.