Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vandana
Starting Member
29 Posts |
Posted - 2013-04-17 : 02:51:33
|
Hi All,i have a table which have product,amount,year,month are the fields.now when in query when i give 2010(eg) year and month 10 i should get output like2009's 12th month along with 2010's all months till 10can anyone suggest me how to get itthanks in advance |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-17 : 03:19:30
|
--May be this?DECLARE @Year INT = 2000, @Month INT = 10SELECT * FROM ProductsWHERE (MonthCol <= @Month AND YearCol = @Year) or (YearCol = @YEAR-1)--Chandu |
|
|
vandana
Starting Member
29 Posts |
Posted - 2013-04-17 : 03:32:32
|
i wana do it without using t-sql |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-17 : 03:34:28
|
How you are passing inputs to the query?SELECT * FROM ProductsWHERE (MonthCol <= 10 AND YearCol = 2010) or (YearCol = 2009)--Chandu |
|
|
|
|
|