Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
look my table

table name: special_ad

id video_id play_mode play_count
1 15 both 2
2 16 after 2
3 17 before 1
4 18 both 2
5 19 after 2

now i want to select a play_mode note equal to 'before' and playcount is minimum.

i'm using the following query but it returns a null value
Select video_id,playmode,play_count from special_ad where play_count=(select min(play_count) from special_ad where playmode<>'before')

it will retrieve if the play_count of 'before' should be higher than others
pls suggest a better way
Posted

1 solution

your Query running well


SQL
Select video_id,play_mode,play_count from video_tbl 
where play_count=(select min(play_count)from video_tbl where play_mode !='before'  group by play_count  ) 


the output of this query is
SQL
video_id  play_mode  play_count 
15	    both	 2
16	    after	 2
18	    both	 2
19	    after	 2
 
Share this answer
 
v3
Comments
Tricube 8-Jul-13 2:53am    
shows syntax error
ErBhati 10-Jul-13 2:32am    
check column name and table name as per your table in database

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900