Click to See Complete Forum and Search --> : SQL query..how do i extend it?


londondevil
May 4th, 2004, 08:14 AM
I am doing the following:


SELECT STORE_STOCK_FRESH.Store_ID StoreID, STORE_STOCK_FRESH.ProductCode Product_Code,
STORE_STOCK_FRESH.Qty_on_Shelf Quantity_on_Shelf,
STORE_STOCK_FRESH.Qty_in_Store Quantity_in_store

FROM STORE_STOCK_FRESH, FRESHGOOD_PRODUCT

WHERE STORE_STOCK_FRESH.Qty_on_shelf<STORE_STOCK_FRESH.Qty_in_Store

AND STORE_STOCK_FRESH.ProductCode=STORE_STOCK_FRESH.ProductCode;



How can i use an IF statement or something to else to print out a messege IF the following statement is FALSE:

WHERE STORE_STOCK_FRESH.Qty_on_shelf<STORE_STOCK_FRESH.Qty_in_Store

hspc
May 4th, 2004, 09:09 AM
Access or SQL server ?

londondevil
May 4th, 2004, 09:27 AM
sorry SQL Server

hspc
May 4th, 2004, 11:09 AM
Hi
I wish this is what you need : (in bold)

SELECT STORE_STOCK_FRESH.Store_ID StoreID, STORE_STOCK_FRESH.ProductCode Product_Code,
STORE_STOCK_FRESH.Qty_on_Shelf Quantity_on_Shelf,
STORE_STOCK_FRESH.Qty_in_Store Quantity_in_store,
CASE When (STORE_STOCK_FRESH.Qty_on_shelf<STORE_STOCK_FRESH.Qty_in_Store) THEN 'Shelf less than Store'
ELSE 'Shelf more or equal store'



FROM STORE_STOCK_FRESH, FRESHGOOD_PRODUCT

WHERE STORE_STOCK_FRESH.ProductCode=STORE_STOCK_FRESH.ProductCode;


the part in bold should be what you need
But i think this query needs some modifications according to the database design and what you want the query to do.
this part :
STORE_STOCK_FRESH.ProductCode=STORE_STOCK_FRESH.ProductCode;
seems meaningless.