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 |
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-22 : 14:59:38
|
| table: morganwedcheckinscheckindate executiontime8/13/2008 8/13/20088/16/2008 8/13/20088/20/2008 8/13/20088/23/2008 8/13/20089/10/2008 8/13/2008 9/13/2008 8/13/2008 8/20/2008 8/20/2008 8/23/2008 8/20/20088/27/2008 8/20/20088/30/2008 8/20/20089/17/2008 8/20/2008 9/20/2008 8/20/2008needs to be matched with Table: Testerhotel roomtype checkindate executiontime id_numClift 1 NULL 8/13/2008 1Clift 2 NULL 8/13/2008 2Clift 3 NULL 8/13/2008 3Clift 4 NULL 8/13/2008 4Clift 5 NULL 8/13/2008 5Clift 6 NULL 8/13/2008 6Clift 7 NULL 8/13/2008 7Clift 8 NULL 8/13/2008 8Clift 9 NULL 8/13/2008 9Clift 10 NULL 8/13/2008 10Clift 1 NULL 8/13/2008 11Clift 2 NULL 8/13/2008 12Clift 3 NULL 8/13/2008 13Clift 4 NULL 8/13/2008 14Clift 5 NULL 8/13/2008 15Clift 6 NULL 8/13/2008 16Clift 7 NULL 8/13/2008 17Clift 8 NULL 8/13/2008 18Clift 9 NULL 8/13/2008 19Clift 10 NULL 8/13/2008 20Clift 1 NULL 8/13/2008 21Clift 2 NULL 8/13/2008 22Clift 3 NULL 8/13/2008 23Clift 4 NULL 8/13/2008 24Clift 5 NULL 8/13/2008 25Clift 6 NULL 8/13/2008 26Clift 7 NULL 8/13/2008 27Clift 8 NULL 8/13/2008 28Clift 9 NULL 8/13/2008 29Clift 10 NULL 8/13/2008 30Clift 1 NULL 8/13/2008 31Clift 2 NULL 8/13/2008 32Clift 3 NULL 8/13/2008 33Clift 4 NULL 8/13/2008 34Clift 5 NULL 8/13/2008 35Clift 6 NULL 8/13/2008 36Clift 7 NULL 8/13/2008 37Clift 8 NULL 8/13/2008 38Clift 9 NULL 8/13/2008 39Clift 10 NULL 8/13/2008 40Clift 1 NULL 8/13/2008 41Clift 2 NULL 8/13/2008 42Clift 3 NULL 8/13/2008 43Clift 4 NULL 8/13/2008 44Clift 5 NULL 8/13/2008 45Clift 6 NULL 8/13/2008 46Clift 7 NULL 8/13/2008 47Clift 8 NULL 8/13/2008 48Clift 9 NULL 8/13/2008 49Clift 10 NULL 8/13/2008 50Clift 1 NULL 8/13/2008 51Clift 2 NULL 8/13/2008 52Clift 3 NULL 8/13/2008 53Clift 4 NULL 8/13/2008 54Clift 5 NULL 8/13/2008 55Clift 6 NULL 8/13/2008 56Clift 7 NULL 8/13/2008 57Clift 8 NULL 8/13/2008 58Clift 9 NULL 8/13/2008 59Clift 10 NULL 8/13/2008 60Clift 1 NULL 8/20/2008 61Clift 2 NULL 8/20/2008 62Clift 3 NULL 8/20/2008 63Clift 4 NULL 8/20/2008 64Clift 5 NULL 8/20/2008 65Clift 6 NULL 8/20/2008 66Clift 7 NULL 8/20/2008 67Clift 8 NULL 8/20/2008 68Clift 9 NULL 8/20/2008 69Clift 10 NULL 8/20/2008 70Clift 1 NULL 8/20/2008 71Clift 2 NULL 8/20/2008 72Clift 3 NULL 8/20/2008 73Clift 4 NULL 8/20/2008 74Clift 5 NULL 8/20/2008 75Clift 6 NULL 8/20/2008 76Clift 7 NULL 8/20/2008 77Clift 8 NULL 8/20/2008 78Clift 9 NULL 8/20/2008 79Clift 10 NULL 8/20/2008 80Clift 1 NULL 8/20/2008 81Clift 2 NULL 8/20/2008 82Clift 3 NULL 8/20/2008 83Clift 4 NULL 8/20/2008 84Clift 5 NULL 8/20/2008 85Clift 6 NULL 8/20/2008 86Clift 7 NULL 8/20/2008 87Clift 8 NULL 8/20/2008 88Clift 9 NULL 8/20/2008 89Clift 10 NULL 8/20/2008 90Clift 1 NULL 8/20/2008 91Clift 2 NULL 8/20/2008 92Clift 3 NULL 8/20/2008 93Clift 4 NULL 8/20/2008 94Clift 5 NULL 8/20/2008 95Clift 6 NULL 8/20/2008 96Clift 7 NULL 8/20/2008 97Clift 8 NULL 8/20/2008 98Clift 9 NULL 8/20/2008 99Clift 10 NULL 8/20/2008 100Clift 1 NULL 8/20/2008 101Clift 2 NULL 8/20/2008 102Clift 3 NULL 8/20/2008 103Clift 4 NULL 8/20/2008 104Clift 5 NULL 8/20/2008 105Clift 6 NULL 8/20/2008 106Clift 7 NULL 8/20/2008 107Clift 8 NULL 8/20/2008 108Clift 9 NULL 8/20/2008 109Clift 10 NULL 8/20/2008 110Clift 1 NULL 8/20/2008 111Clift 2 NULL 8/20/2008 112Clift 3 NULL 8/20/2008 113Clift 4 NULL 8/20/2008 114Clift 5 NULL 8/20/2008 115Clift 6 NULL 8/20/2008 116Clift 7 NULL 8/20/2008 117Clift 8 NULL 8/20/2008 118Clift 9 NULL 8/20/2008 119Clift 10 NULL 8/20/2008 120to create this table...hotel roomtype checkindate executiontimeClift 1 8/13/2008 8/13/2008Clift 2 8/13/2008 8/13/2008Clift 3 8/13/2008 8/13/2008Clift 4 8/13/2008 8/13/2008Clift 5 8/13/2008 8/13/2008Clift 6 8/13/2008 8/13/2008Clift 7 8/13/2008 8/13/2008Clift 8 8/13/2008 8/13/2008Clift 9 8/13/2008 8/13/2008Clift 10 8/13/2008 8/13/2008Clift 1 8/16/2008 8/13/2008Clift 2 8/16/2008 8/13/2008Clift 3 8/16/2008 8/13/2008Clift 4 8/16/2008 8/13/2008Clift 5 8/16/2008 8/13/2008Clift 6 8/16/2008 8/13/2008Clift 7 8/16/2008 8/13/2008Clift 8 8/16/2008 8/13/2008Clift 9 8/16/2008 8/13/2008Clift 10 8/16/2008 8/13/2008Clift 1 8/20/2008 8/13/2008Clift 2 8/20/2008 8/13/2008Clift 3 8/20/2008 8/13/2008Clift 4 8/20/2008 8/13/2008Clift 5 8/20/2008 8/13/2008Clift 6 8/20/2008 8/13/2008Clift 7 8/20/2008 8/13/2008Clift 8 8/20/2008 8/13/2008Clift 9 8/20/2008 8/13/2008Clift 10 8/20/2008 8/13/2008Clift 1 8/23/2008 8/13/2008Clift 2 8/23/2008 8/13/2008Clift 3 8/23/2008 8/13/2008Clift 4 8/23/2008 8/13/2008Clift 5 8/23/2008 8/13/2008Clift 6 8/23/2008 8/13/2008Clift 7 8/23/2008 8/13/2008Clift 8 8/23/2008 8/13/2008Clift 9 8/23/2008 8/13/2008Clift 10 8/23/2008 8/13/2008Clift 1 9/10/2008 8/13/2008Clift 2 9/10/2008 8/13/2008Clift 3 9/10/2008 8/13/2008Clift 4 9/10/2008 8/13/2008Clift 5 9/10/2008 8/13/2008Clift 6 9/10/2008 8/13/2008Clift 7 9/10/2008 8/13/2008Clift 8 9/10/2008 8/13/2008Clift 9 9/10/2008 8/13/2008Clift 10 9/10/2008 8/13/2008Clift 1 9/13/2008 8/13/2008Clift 2 9/13/2008 8/13/2008Clift 3 9/13/2008 8/13/2008Clift 4 9/13/2008 8/13/2008Clift 5 9/13/2008 8/13/2008Clift 6 9/13/2008 8/13/2008Clift 7 9/13/2008 8/13/2008Clift 8 9/13/2008 8/13/2008Clift 9 9/13/2008 8/13/2008Clift 10 9/13/2008 8/13/2008Clift 1 8/20/2008 8/20/2008Clift 2 8/20/2008 8/20/2008Clift 3 8/20/2008 8/20/2008Clift 4 8/20/2008 8/20/2008Clift 5 8/20/2008 8/20/2008Clift 6 8/20/2008 8/20/2008Clift 7 8/20/2008 8/20/2008Clift 8 8/20/2008 8/20/2008Clift 9 8/20/2008 8/20/2008Clift 10 8/20/2008 8/20/2008Clift 1 8/23/2008 8/20/2008Clift 2 8/23/2008 8/20/2008Clift 3 8/23/2008 8/20/2008Clift 4 8/23/2008 8/20/2008Clift 5 8/23/2008 8/20/2008Clift 6 8/23/2008 8/20/2008Clift 7 8/23/2008 8/20/2008Clift 8 8/23/2008 8/20/2008Clift 9 8/23/2008 8/20/2008Clift 10 8/27/2008 8/20/2008Clift 1 8/27/2008 8/20/2008Clift 2 8/27/2008 8/20/2008Clift 3 8/27/2008 8/20/2008Clift 4 8/27/2008 8/20/2008Clift 5 8/27/2008 8/20/2008Clift 6 8/27/2008 8/20/2008Clift 7 8/27/2008 8/20/2008Clift 8 8/27/2008 8/20/2008Clift 9 8/27/2008 8/20/2008Clift 10 8/27/2008 8/20/2008Clift 1 8/30/2008 8/20/2008Clift 2 8/30/2008 8/20/2008Clift 3 8/30/2008 8/20/2008Clift 4 8/30/2008 8/20/2008Clift 5 8/30/2008 8/20/2008Clift 6 8/30/2008 8/20/2008Clift 7 8/30/2008 8/20/2008Clift 8 8/30/2008 8/20/2008Clift 9 8/30/2008 8/20/2008Clift 10 8/30/2008 8/20/2008Clift 1 9/17/2008 8/20/2008Clift 2 9/17/2008 8/20/2008Clift 3 9/17/2008 8/20/2008Clift 4 9/17/2008 8/20/2008Clift 5 9/17/2008 8/20/2008Clift 6 9/17/2008 8/20/2008Clift 7 9/17/2008 8/20/2008Clift 8 9/17/2008 8/20/2008Clift 9 9/17/2008 8/20/2008Clift 10 9/17/2008 8/20/2008Clift 1 9/20/2008 8/20/2008Clift 2 9/20/2008 8/20/2008Clift 3 9/20/2008 8/20/2008Clift 4 9/20/2008 8/20/2008Clift 5 9/20/2008 8/20/2008Clift 6 9/20/2008 8/20/2008Clift 7 9/20/2008 8/20/2008Clift 8 9/20/2008 8/20/2008Clift 9 9/20/2008 8/20/2008Clift 10 9/20/2008 8/20/2008any help? I triedselect t.hotel, t.roomtype, s.checkindate, t.roomrate, t.executiontime, t.table_numfrom tester as t inner join morganwedcheckins as s on t.executiontime = s.executiontime where s.executiontime = t.executiontime but came up with too many matches. THANK YOU |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-08-22 : 15:05:58
|
| Don't put the condition in both the JOIN and the WHERE clause. Since you are using the ANSI syntax, just put it in the JOIN, meaning after ON. You need to show us what rows need to be returned and why your current query isn't working.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-22 : 15:09:48
|
quote: Originally posted by tkizer Don't put the condition in both the JOIN and the WHERE clause. Since you are using the ANSI syntax, just put it in the JOIN, meaning after ON. You need to show us what rows need to be returned and why your current query isn't working.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog
the desired result set is the third block of data above. My current query isn't working because its returning 720 rows of data where its matching up things that aren't suppose to be. I'm only expecting 120 rows |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-08-22 : 15:11:08
|
| Could you trim your post down to just a few rows? I don't have the time to go through all of that data. We typically only need 5-10 rows.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-22 : 15:16:35
|
| I got it!!select t.hotel, t.roomtype, s.checkindate, t.roomrate, t.executiontimefrom tester as t inner join morganwedcheckins as s on t.executiontime = s.executiontimeorder by t.hotel, t.roomtype, s.checkindate, t.roomrate, t.executiontimeis what I needed!! Thanks Tara! |
 |
|
|
|
|
|
|
|