| Author |
Topic |
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-27 : 15:23:47
|
| Dear Friends,I have two tables called Pricing and Booking , i have the below sample data,Pricing ----------BoatId From To PricePerDay1 7/3/2009 13/3/2009 101 14/3/2009 3/4/2009 51 4/4/2009 24/4/2009 62 7/3/2009 31/3/2009 202 1/4/2009 15/4/2009 103 7/3/2009 25/3/2009 50Description : The pricing table will contain the price for the boat in different dateBooking----------BoatId From To TotalPrice1 21/3/2009 27/3/2009 351 4/4/2009 17/4/2009 842 7/3/2009 11/3/2009 1002 28/3/2009 4/4/2009 1203 9/3/2009 17/3/2009 450Description : The booking table contain the booking details of various boat in the various dateMy Expected output isWhere BoatId=2---------------From To PricePerDay Available 7/3/2009 11/3/2009 20 No12/3/2009 27/3/2009 20 Yes28/3/2009 31/3/2009 20 No1/4/2009 4/4/2009 10 No5/4/2009 15/4/2009 10 YesWhere BoatId=1----------------From To PricePerDay Available 7/3/2009 13/3/2009 10 Yes14/3/2009 20/3/2009 5 Yes21/3/2009 27/3/2009 5 No28/3/2009 31/3/2009 5 Yes4/4/2009 17/4/2009 6 No18/4/2009 24/4/2009 6 YesWhere BoatId=3---------------From To PricePerDay Available 7/3/2009 8/3/2009 50 Yes9/3/2009 17/3/2009 50 NO18/3/2009 25/3/2009 5 YesPlease help me to get the expected output.Thanks in Advance |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-27 : 23:09:19
|
| Dear Friends, Please help out to get the expected out.Thanks in Advance |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-28 : 07:37:20
|
| Friends, I am could not able to find the solution for this.Please help me to get the expected output.Thanks in Advance |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-29 : 01:25:47
|
| Hello Friends,I am still looking for the query to get expected outputThanks in Advance |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-29 : 03:37:39
|
| Friends, Whether this is possible to get the expected output, or am i missing something,Please let me know if i need to provide some more details, I am sorry if my question is wrong, Please let me knowThanks in Advance |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-29 : 03:46:44
|
| Are you using sql 2005? |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-29 : 06:24:29
|
| Dear Visakh,Thank you for your response.No, i am using SQL server 2000Please help me to get the expected output for meThanks in advance |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-29 : 13:56:01
|
| Hello Friends, I am still waiting for your reply,Hope i can get a expected output with your help hereThanks in advance |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-03-31 : 07:34:16
|
| Friends,could any one please help me to get the expected outputThanks in Advance |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-03-31 : 08:19:00
|
| What have you tried so far?[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-04-13 : 01:00:04
|
| Friends,I have tried with below query but not yet i got the expected outputSELECT c.fromDate , c.ToDate , CASE WHEN b.BoatId IS NULL THEN 'YES' ELSE 'NO' END AS Available,c.PriceFROM(SELECT BoatId,Price,FromDate,FromDate + 7 AS ToDateFROM(SELECT BoatId,Price,ToDate,CASE WHEN DATEPART(DW,DATEADD(day,Number,FromDate))%7 = 0 THEN DATEADD(day,Number,FromDate) END AS FromDateFROM CC_BoatAllocation , (SELECT number FROM MASTER..SPT_VALUES WHERE TYPE = 'P') nWHERE BoatId = 2 AND DATEADD(day,Number,FromDate) < ToDate)tWHERE FromDate IS NOT NULL) cLEFT JOIN CC_BoatBooking bON c.BoatId = b.BoatIdAND c.fromDate = b.fromDate AND c.ToDate = b.ToDate Help me out to get the expected output,Thanks in advance. |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2009-04-13 : 16:18:01
|
| is it possible to get the expected output using sql query, or i need to change the table design please let me know |
 |
|
|
|