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 |
|
hanhtn
Starting Member
2 Posts |
Posted - 2011-07-27 : 08:01:59
|
| Hi AllI have sql: select * from tblCar where TranDate >= '2011-06-09' and Trandate <= '2011-06-20'CarID, CarType, TranDate, Type, Quantity2563 BMW 2011-06-09 Hold -15 (1)2563 BMW 2011-06-20 Return 15 (2)2563 BMW 2011-06-20 Hold 20 (3) .... ABC ......... IMF ..... And when I change the conditions of that sql as following:select * from tblCar where TranDate >= '2011-06-10' and Trandate <= '2011-06-19'==> all the results was disappearedBecause you can know that a person borrow car 'BMW' from '2011-06-09' and until '2011-06-20' he returned it. So how can I keep the record (1) in the range date from '2011-06-09' to '2011-06-19'Please help me.Thanks you so much |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-27 : 08:41:10
|
we should know more about the relation between the rows via CarID and Type... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
hanhtn
Starting Member
2 Posts |
Posted - 2011-07-27 : 10:50:23
|
| Hi Webfred and AllSorry, last time too brieflyThis table should be like this: TBL_CAR_TXTranID, AccID, CarID, TranDate, Type, Quantity, .....--------------------------------------------------------0 2563 BMW 2011-06-09 H -151 2563 BMW 2011-06-20 R 15 2 2563 BMW 2011-06-20 H 20 3 0055 TOY 2011-06-12 H -104 0055 TOY 2011-06-15 R 55 0055 TOY 2011-06-20 R 5 ...(H): Hold, (R): Release (don't have table for TYPE)table TBL_CAR:MarketID, CarID, Name, Size, ...---------------------------GER BMW JPA TOYTable TBL_PERSON:AccID, Name, Age, DOB, ...-------------------------2563 Robert0055 MikeIf you know please help me.Thanksss |
 |
|
|
|
|
|
|
|