shamsundar  bobade

shamsundar bobade

  • NA
  • 24
  • 10.5k

Query

Feb 19 2014 6:31 AM
DECLARE
@SongYear varchar(50),
@YearBack varchar(50),
@YearPost varchar(50),
@Singer varchar(50),
@Composer varchar(50)

--Song Option First By Year +/- 3
set @SongYear=(select [year] from tbl_SongMaster where song_id=@songid)
 
set @YearBack=@SongYear-3
set @YearPost=@SongYear+3
select top(1)song As FirstOption from tbl_SongMaster where year between @YearBack and @YearPost  ORDER BY NEWID()

--Song Option Second By Same Singer
set @Singer=(select singer1 from tbl_SongMaster where song_id=@songid)
select Top(1) song as SecondOption from tbl_SongMaster where singer1=@Singer order by NEWID()

--Song Option Third And Fourth By Composer
set @Composer=(select composer1 from tbl_SongMaster where song_id=@songid)
select top(2) song from tbl_SongMaster where composer1=@Composer order by NEWID()






 i get three result can i combine it in one result plz answer fast





Answers (3)