Viewing 15 posts - 376 through 390 (of 898 total)
It will be better if you provide DDL and sample data in a ready to use format so that volunteers here can copy+paste it in their machine and start working...
February 22, 2013 at 12:09 am
The below code will help you handle the overlapping conditions
SELECTBookings.Booking_Skey,
SUM (
(
DATEDIFF(
DAY,
CASE
WHEN PitchValues.StartDate BETWEEN Bookings.ArrivalDate AND Bookings.DepartureDate THEN PitchValues.StartDate
ELSE Bookings.ArrivalDate
END,
CASE
WHEN PitchValues.EndDate BETWEEN Bookings.ArrivalDate AND Bookings.DepartureDate THEN PitchValues.EndDate
ELSE Bookings.DepartureDate
END
) +...
February 21, 2013 at 10:19 am
wafw1971 (2/21/2013)
I didn't think of that and I should have, each price is a daily price so if the price for a pitch is £9.00 on the 31/01/2010 and...
February 21, 2013 at 8:13 am
wafw1971 (2/21/2013)
Hi KingstonThat's has worked thank you so much, I cannot believe it was one line of code.
Thanks again
Wayne
Great 🙂
Looking at your code, I have a question.
Which price should you...
February 21, 2013 at 7:57 am
Your query is basically joining the 1 row in Bookings table with 4 rows in PitchValues table
You will need one more condition on date to filter it down to one...
February 21, 2013 at 7:35 am
Can you give us the results of the below mentioned queries
SELECT * FROM Bookings WHERE Booking_Skey = 1
SELECT * FROM PitchValues WHERE PitchType_Skey IN ( SELECT PitchType_Skey FROM Bookings WHERE...
February 21, 2013 at 7:03 am
Sean Pearce (2/21/2013)
SELECT * FROM PseudoTable WHERE Item LIKE '%tea%'
1 row returned.
INSERT INTO PseudoTable VALUES ('Tear')
INSERT INTO PseudoTable VALUES ('Bike')
INSERT INTO PseudoTable VALUES ('Monkey')
SELECT * FROM...
February 21, 2013 at 6:08 am
vchauhan_me (2/21/2013)
February 21, 2013 at 5:53 am
vchauhan_me (2/21/2013)
February 21, 2013 at 5:39 am
It depends on your business requirement( What are you going to do with this 70,000 words? )
If you intend to handle each word differently by joining them individually to some...
February 21, 2013 at 4:44 am
Even this would do the work for you and is probably much simpler
SELECTCONVERT(TIME, DATEADD(SECOND, DATEDIFF(SECOND, minibgtime, maxendtime), '' ) )
FROMtablename
February 21, 2013 at 12:33 am
This should help
WHERE a.connected = 0 AND ( dt.connected IS NOT NULL OR b.id IS NULL )
Even the below code will solve your requirement if you are using SQL Server...
February 20, 2013 at 7:45 am
change your WHERE Clause like below
WHERE A.connected = 0 AND dt.connected IS NOT NULL
February 20, 2013 at 5:11 am
This should help you out
; WITH cte_Delete_Dups AS
(
SELECTROW_NUMBER() OVER ( PARTITION BY row_id, ename, job, sal ORDER BY row_id ) AS RN, *
FROMempl
)
DELETE
FROMcte_Delete_Dups
WHERErn > 1
February 20, 2013 at 12:48 am
You can use Dynamic CROSS-TABS to achieve this
You can have a look at the below mentioned articles for more details on CROSS-TABS
http://www.sqlservercentral.com/articles/T-SQL/63681/
http://www.sqlservercentral.com/articles/Crosstab/65048/
Something like below
DECLARE@strColumns VARCHAR(MAX)
DECLARE@strSQL VARCHAR(MAX)
IF OBJECT_ID('tempdb..#tmp_table') IS NOT NULL
DROP...
February 19, 2013 at 7:52 am
Viewing 15 posts - 376 through 390 (of 898 total)