Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
problem

How to get cost per hotel and flight then add it in duration cost table based on flight date automatically ?

Details

suppose i write flight date

26/07/2017 alexia 8days 04/08/2017

it must automatically get cost from hotel price table and price from flight

then add it in duration cost table

so that

what query i write to get cost per hotel and flight when write flight date then insert

it to duration cost table my database

SQL
CREATE TABLE program(
     ProgramID int primary key not null, 
    ProgramName varchar(30)
     ) 
    GO
     insert into program values(1,'Alexia'),(2,'Amon'),(3,'Sfinx') 
    GO
    CREATE TABLE ProgramDuration(
    DurationNo int primary key not null,
    programID int not null,
    Duration varchar(30) null
    )
    insert into ProgramDurationvalues(1,1,'3 for Alexia'),(2,1,'5 for Alexia')
    GO
    CREATE TABLE DurationDetail(
     DurationNo int not null,
     [Days]  varchar(20) not null, 
    HotelID int null,
     FlightID int null
    )
     insert into DurationDetail values (2,'Day1',1,'amsterdam to luxor','airport to hotel'), (2,'Day2',1,null,'AbuSimple musuem'), 
    (2,'Day3',1,null), 
    (2,'Day4',1,null),
     (2,'Day5',1,'Luxor to amsterdam') 
    GO
    CREATE TABLE DurationCost(
    DurationNo int not null,
    [Date] date not null,
    Hote_cost numeric(18,0) null,
    Flight_cost numeric(18,0) null,
    Transfer_cost numeric(18,0) null
    )
    insert into DurationCostvalues(
    2,'2017-06-25',25,500,20),
    (2,'2017-06-26',25,null,55),
    (2,'2017-06-27',25,null,null),
    (2,'2017-06-28',25,null,null),
    (2,'2017-06-29',25,500,null)
    GO
    CREATE TABLE [dbo].[FlightData](
        [FlighID] [nvarchar](50) NOT NULL,
        [FlightNo] [nvarchar](50) NOT NULL,
        [FlightDate] [datetime] NULL,
        [FlightTypeID] [int] NULL,
        [AirLine] [nvarchar](50) NULL,
        [Arrival] [time](7) NULL,
        [Departure] [time](7) NULL,
        [Price] [money] NULL,
        [Active] [bit] NULL
    )
      insert into FlightData values (1,'ms300',1,'egyptairline','6','10',200,1)
    CREATE TABLE [dbo].[FlightRoute](
        [FlightTypeID] [int] NOT NULL,
        [FlightFrom] [nvarchar](max) NULL,
        [FlightTo] [nvarchar](max) NULL,
        [Active] [bit] NULL,
        [FlightRouteWay] [nvarchar](max) NULL,
    )
    insert into FlightRoute values (1,'amsterdam','cairo',1,amsterdam to cairo), (2,'cairo','amsterdam',1,cairo to amsterdam)
    CREATE TABLE [dbo].[Hotel](
        [ProductID] [int] NOT NULL,
        [ProductName] [nvarchar](50) NULL,
     )
     insert into Hotel values (1,'Hilton'), (2,'Movenpick')
    CREATE TABLE [dbo].[HotelPrice](
        [ProductPriceID] [int] NOT NULL,
        [ProductID] [int] NULL,
        [FromDate] [datetime] NULL,
        [ToDate] [datetime] NULL,
        [HotelPrice] [numeric](18, 0) NULL,
    )
insert into HotelPrice values (1,1,01/07/2017,01-09-2017,20$), (2,1,02-09-2017,02-11-2017,30)


What I have tried:

How to add cost per hotel and flight in duration cost table
Posted
Updated 27-Jun-17 15:04pm
v2
Comments
Patrice T 27-Jun-17 20:41pm    
Third time the same question. please no repost
PIEBALDconsult 27-Jun-17 20:53pm    
You'd have it done by now if you concentrated on it instead of asking for us to do it for you.
ahmed_sa 27-Jun-17 20:59pm    
ok i need to how to insert cost from flight and hotel in table cost duration
ahmed_sa 27-Jun-17 21:01pm    
i will not repost again but please can any one help me in that if possible

1 solution

Already 74 questions and 3 times this one.
If no one answer this, there is a reason, may be helpers are fed-up helping you on so many questions and may be they think it is time to learn things yourself.
Quote:
How to get cost per hotel and flight then add it in duration cost table based on flight date automatically ?

First step: you need to learn and understand database design and SQL.
second step; use your brain.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
 
Share this answer
 
Comments
BillWoodruff 27-Jun-17 23:56pm    
Good advice, but this ia a comment, not a solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900