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 |
san79
Starting Member
42 Posts |
Posted - 2008-12-16 : 07:23:55
|
dear all,sorry if this is very naive, but i dont know how to do it.i am having two tables registration and regisdatesthe fields in the registration tables arerno number PKrdt datetimesdt datetimeedt datetimecustname varcharthe fields in regisdates arerno number fk to registration.rnoregisdate datetimebasically the customer register in the registration table, he is assigned to use the facility between the sdt and edtthen he have to choose certain dates between the sdt and edt to avail and these dates are stored in the regisdates table.now the problem is i wish to take date wise registered customer list. i wish the customers in regisdates table should be appear only on the registered date in the report, currently i am using between keyword to filter records in the registration table sdt and edt fields. the customer who is availed choose date option is also displayed with other customers. i want to show him only on the particular registered dates. any suggestions is greatly appreciatedthanks and regards |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-16 : 07:44:35
|
[code]SELECT r.*FROM registration rLEFT JOIN regisdates rdON rd.rno=r.rnoAND rd.regisdate BETWEEN sdt AND DATEADD(dd,1,edt)WHERE (rd.rno IS NULLOR rd.regisdate = @YourDate)AND r.rdt=@YourDate[/code]@YourDate is date passed |
|
|
san79
Starting Member
42 Posts |
Posted - 2008-12-16 : 07:57:31
|
sir,will try and get backthankyou very much |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-16 : 08:02:15
|
yup...no probsyou're welcome |
|
|
san79
Starting Member
42 Posts |
Posted - 2008-12-17 : 22:59:38
|
sir, i have sorted out the issue partially using your query and partially using rowdatabound in gridviewbut i feel that the actually i would like to know is there is a single query available to represent the data the data in the table look like this table name is tblregistrationrno rdate sdt edt custname1 12/17/2008 12/17/2008 12/20/2008 xyz2 12/18/2008 12/18/2008 1/18/2009 abcand the tbldates is having values like thisrno sdate2 12/20/20082 12/30/20082 12/1/20092 1/15/2009now when i display the customer for date 19/12/2008 then receiptno 1 should only appear because it is assumed that if the receiptno dosenot have value in tbldates then he is considered to be using the facility throughout sdt and edt. now when i display the customer for date 20/12/2008 then receiptno 1 and 2 should appear because the he is specified his pref in tbldates table. i think i am little bit clear now. please advice me if i have to change the structure of the tables or what should i do to get it done or if it is possible in single query.sorry for the bit long mail.thanks in advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-17 : 23:45:54
|
[code]SELECT r.*FROM registration rLEFT JOIN regisdates rdON rd.rno=r.rnoAND rd.sdate BETWEEN r.sdt AND r.edtWHERE ( rd.sdate = @YourDateOR @YourDate BETWEEN r.sdt AND r.edt)[/code] |
|
|
|
|
|