Jump to content

Sort data by FIFO


metalpain

Recommended Posts

Hi all i am having trouble understanding the a FIFO concept.

 

i have pusedo waiting list for a houses on a waiting list table, more than two potential tenants can bid for a property what i would like to do is filter the data by a fifo style query based on the start date. i would like some guidance on how to perform this.

CREATE TABLE Waiting_list(

Waiting# SMALLINT IDENTITY(0001,1) not null, 
Customer# BIGINT , 
Property# SMALLINT not null,   
Tenant# BIGINT,
Waiting_Start_date SMALLDATETIME, 
Waiting_Property_type CHAR(10),
Rent_offer SMALLMONEY, 

CONSTRAINT WAITING_LIST_PK PRIMARY KEY (Waiting#),
CONSTRAINT WAITING_PROPERTIES_FK FOREIGN KEY (Property#)REFERENCES Properties(Property#),
CONSTRAINT WAITING_TENANT_FK FOREIGN KEY (Tenant#)REFERENCES Tenant(Tenant#),
CONSTRAINT WAITING_CUSTOMER_FK FOREIGN KEY (Customer#)REFERENCES Customer(Customer#)
);

INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200000,15,'House','2008-10-21',150);  
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200005,2,'Town House','2008-11-1',130);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200010,2,'Unit','2008-10-15',190);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200015,20,'Villa','2008-12-20',200);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200020,18,'House','2008-09-1',200);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200025,19,'Unit','2008-11-01',250);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200030,20,'Unit','2008-09-17',190);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200035,18,'House','2008-12-12',230);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200040,11,'Villa','2008-11-23',210);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200045,16,'House','2008-09-30',250);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200050,22,'Unit','2009-1-1',200);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200055,8,'Villa','2008-11-1',170);
INSERT INTO Waiting_list (Customer#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(200060,20,'Unit','2008-10-12',185);
INSERT INTO Waiting_list (Tenant#,Property#,Waiting_Property_type,Waiting_Start_date, Rent_offer)
VALUES(100018,5,'Town House','2008-11-2',190);

EDITed ... for code tags

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.