Buenas tengo una base de datos para gestionar un alquiler de bicicletas, quiero saber las bicicletas cuya fecha de devolución [FeDev] sea inferior a la fecha actual.
BICICLETA
CREATE TABLE [dbo].[BICICLETA] (
[IdBici] NCHAR (10) NOT NULL,
[marca] NVARCHAR (15) NOT NULL,
[precio] MONEY NULL,
[alquilada] BIT NULL,
CONSTRAINT [PK_BICICLETA] PRIMARY KEY CLUSTERED ([IdBici] ASC)
);
ALQUILER
CREATE TABLE [dbo].[ALQUILER] (
[IdAlquiler] BIGINT NOT NULL,
[FeAlquiler] DATE NULL,
[FeDev] DATE NULL,
[IdBici] NCHAR (10) NOT NULL,
[IdCliente] NCHAR (20) NOT NULL,
CONSTRAINT [PK_ALQUILER] PRIMARY KEY CLUSTERED ([IdAlquiler] ASC),
CONSTRAINT [FK_ALQUILER_BICI] FOREIGN KEY ([IdBici]) REFERENCES [dbo].[BICICLETA] ([IdBici]),
CONSTRAINT [FK_ALQUILER_CLIENTE] FOREIGN KEY ([IdCliente]) REFERENCES [dbo].[CLIENTE] ([IdCliente])
);
BICICLETA
CREATE TABLE [dbo].[BICICLETA] (
[IdBici] NCHAR (10) NOT NULL,
[marca] NVARCHAR (15) NOT NULL,
[precio] MONEY NULL,
[alquilada] BIT NULL,
CONSTRAINT [PK_BICICLETA] PRIMARY KEY CLUSTERED ([IdBici] ASC)
);
ALQUILER
CREATE TABLE [dbo].[ALQUILER] (
[IdAlquiler] BIGINT NOT NULL,
[FeAlquiler] DATE NULL,
[FeDev] DATE NULL,
[IdBici] NCHAR (10) NOT NULL,
[IdCliente] NCHAR (20) NOT NULL,
CONSTRAINT [PK_ALQUILER] PRIMARY KEY CLUSTERED ([IdAlquiler] ASC),
CONSTRAINT [FK_ALQUILER_BICI] FOREIGN KEY ([IdBici]) REFERENCES [dbo].[BICICLETA] ([IdBici]),
CONSTRAINT [FK_ALQUILER_CLIENTE] FOREIGN KEY ([IdCliente]) REFERENCES [dbo].[CLIENTE] ([IdCliente])
);