I'm creating a stored procedure that gets values from a table that stores projects funding (their id, their goal and what they've received so far) And the proc would return either the project ID's that have been fully funded or those that haven't given a parameter @querytype; but I don't know how to put an if condition in a where; I've only ever used them in the select portion of a statement.
This is what I have so far but it just gives me "INCORRECT SYNTAX" on the first case...
--create proc Projects.GetFundedProjects -- Projects that have reached their goal
create proc Projects.GetFundedProjects
(@QueryType int
)
as
begin
select * from Stats.FundedProjectsToday
CASE
WHEN @QueryType = 1 -- Projects that reached their goal
THEN
where AUReceived=>ProjectGoal
WHEN @QueryType = 2 -- Projects that have not been funded
THEN
where AUReceived<ProjectGoal
end --end the case
end -- end the proc
Aucun commentaire:
Enregistrer un commentaire