hi,
i have table with following feilds
ProgramId ProgramType AccountName ProgramName ProgramBudget ProgramStatus
I need to write a search query to generate a report where search criteria will be (ProgramType=1,2,3 or All of above),(AccountName=a,b,c or All of above),(ProgramStatus=y,n or all of above)
any clues,
thnx in advance
sudheer.hi,
try something like this:
declare @.PID int, @.PTY int
set @.PID=null -- will search "all"
set @.PID=2 -- will search for ProgramID=2 etc
:
:
select *
from <tablename>
where ((@.PID is null) or (ProgramID=@.PID)) and
((@.PTY is null) or (ProgramType=@.PTY))
:
markus
Wednesday, March 7, 2012
Help Needed
Labels:
accountname,
database,
feildsprogramid,
following,
microsoft,
mysql,
oracle,
programbudget,
programname,
programstatusi,
programtype,
query,
search,
server,
sql,
table,
write
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment