Friday, March 23, 2012

how to find vacant slot of rack

Dear All,

i want to find no of empty rack(two dimensional ) . i am using sql2000

i have a rack of two dimensional where every slot is recognized by rowno and columnno now in every slot i placed item (captured by itemcode). nOw i want to find slot do not assing any item
please give me some idea

there is rackmst( where i define max_no_row and max_no_cols).

Please help


thanks

I too have the same doubt and i'll be thankful to u if u forward ur answers|||

Perhaps something like this would help:

CREATE TABLE MyRack
( RowNo int,
ColNo int,
Slot varchar(10)
PRIMARY KEY ( RowNo, ColNo )
)

INSERT INTO MyRack VALUES ( 1, 1, 'a25' )
INSERT INTO MyRack VALUES ( 1, 2, 'a24' )
INSERT INTO MyRack VALUES ( 1, 3, 'a23' )
INSERT INTO MyRack VALUES ( 1, 4, 'a28' )
INSERT INTO MyRack VALUES ( 2, 1, NULL )
INSERT INTO MyRack VALUES ( 2, 2, 'b25' )
INSERT INTO MyRack VALUES ( 2, 3, 'c25' )
INSERT INTO MyRack VALUES ( 2, 4, 'd25' )
INSERT INTO MyRack VALUES ( 3, 1, NULL )
INSERT INTO MyRack VALUES ( 3, 2, 'h25' )
INSERT INTO MyRack VALUES ( 3, 3, 'j25' )
INSERT INTO MyRack VALUES ( 3, 4, 'k25' )

SELECT TOP 1
RowNo,
ColNo
FROM MyRack
WHERE Slot IS NULL
ORDER BY
RowNo,
ColNo

No comments:

Post a Comment