Click here to Skip to main content
15,917,991 members
Home / Discussions / Database
   

Database

 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Nick Parker15-Oct-02 16:38
protectorNick Parker15-Oct-02 16:38 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug16-Oct-02 12:47
Doug16-Oct-02 12:47 
Generalmsado15.dll Pin
stevenson11-Oct-02 20:11
stevenson11-Oct-02 20:11 
GeneralRe: msado15.dll Pin
Michael P Butler12-Oct-02 1:55
Michael P Butler12-Oct-02 1:55 
GeneralQuestion about Transact SQL Pin
tongc11-Oct-02 6:38
tongc11-Oct-02 6:38 
GeneralRe: Question about Transact SQL Pin
Richard Deeming11-Oct-02 7:10
mveRichard Deeming11-Oct-02 7:10 
GeneralRe: Question about Transact SQL Pin
tongc11-Oct-02 13:48
tongc11-Oct-02 13:48 
GeneralRe: Question about Transact SQL Pin
Richard Deeming13-Oct-02 22:47
mveRichard Deeming13-Oct-02 22:47 
Whoops! Blush | :O
--Store the first and last day of the month (July 2001)
DECLARE @StartMonth smalldatetime, @EndMonth smalldatetime 
SELECT
     --First of the month
    @StartMonth = CAST('1 July 2001' As smalldatetime),
     --Day before the first of the next month
    @EndMonth = DATEADD(day, -1, DATEADD(month, 1, @StartMonth))
 
SELECT
    --Hotel details
    HOTEL.Hotel_No,
    HOTEL.Hotel_Name,
    HOTEL.Address,
 
    --Total income per hotel
    SUM(Bookings.Income) As Income
 
FROM
    HOTEL INNER JOIN
    (
        --Calculate the income as Room price (per night) * # nights
        SELECT
            ROOM.Hotel_No,
            CASE
                --Booking started before the month
                WHEN Date_From < @StartMonth THEN
                    DATEDIFF(day, @StartMonth, Date_To) * ROOM.Price
 
                --Booking finished after the month
                WHEN Date_To > @EndMonth THEN
                    DATEDIFF(day, Date_From, @EndMonth) * ROOM.Price
 
                --Booking was entirely within the month
                ELSE
                    DATEDIFF(day, Date_From, Date_To) * ROOM.Price
            END As Income
  
        FROM
            BOOKING INNER JOIN ROOM
            ON ROOM.Room_No = BOOKING.Room_No
 
        WHERE
        --Only want bookings that intersect the month
            Date_From < @EndMonth
        AND
            Date_To > @StartMonth
    )
    As Bookings
 
    ON Bookings.Hotel_No = HOTEL.Hotel_No
 
WHERE
--Only want bookings for the Sheridan hotels
    Hotel_Name = 'Sheridan Hotel'
 
GROUP BY
    HOTEL.Hotel_No,
    HOTEL.Hotel_Name,
    HOTEL.Address

GeneralSQL Suggestions. Pin
Chris Meech11-Oct-02 4:24
Chris Meech11-Oct-02 4:24 
GeneralRe: SQL Suggestions. Pin
Jon Hulatt11-Oct-02 5:52
Jon Hulatt11-Oct-02 5:52 
GeneralRe: SQL Suggestions. Pin
Richard Deeming11-Oct-02 7:23
mveRichard Deeming11-Oct-02 7:23 
GeneralRe: SQL Suggestions. Pin
Chris Meech15-Oct-02 3:36
Chris Meech15-Oct-02 3:36 
GeneralFast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 3:12
professionalLuca Leonardo Scorcia11-Oct-02 3:12 
GeneralRe: Fast SELECT Count Pin
Jon Hulatt11-Oct-02 3:42
Jon Hulatt11-Oct-02 3:42 
GeneralRe: Fast SELECT Count Pin
Daniel Turini11-Oct-02 3:52
Daniel Turini11-Oct-02 3:52 
GeneralRe: Fast SELECT Count Pin
Jon Hulatt11-Oct-02 4:23
Jon Hulatt11-Oct-02 4:23 
GeneralRe: Fast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 6:55
professionalLuca Leonardo Scorcia11-Oct-02 6:55 
GeneralRe: Fast SELECT Count Pin
Daniel Turini14-Oct-02 0:55
Daniel Turini14-Oct-02 0:55 
QuestionOnly 255 char? Pin
Rickard Andersson2010-Oct-02 21:30
Rickard Andersson2010-Oct-02 21:30 
AnswerRe: Only 255 char? Pin
Mazdak10-Oct-02 22:01
Mazdak10-Oct-02 22:01 
GeneralRe: Only 255 char? Pin
Rickard Andersson2010-Oct-02 22:40
Rickard Andersson2010-Oct-02 22:40 
GeneralRe: Only 255 char? Pin
Nick Parker11-Oct-02 1:31
protectorNick Parker11-Oct-02 1:31 
GeneralRe: Only 255 char? Pin
Rickard Andersson2011-Oct-02 2:05
Rickard Andersson2011-Oct-02 2:05 
GeneralCascading delete in a self-joined table Pin
Wjousts10-Oct-02 10:14
Wjousts10-Oct-02 10:14 
GeneralRe: Cascading delete in a self-joined table Pin
Daniel Turini10-Oct-02 10:45
Daniel Turini10-Oct-02 10:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.