Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mkgmahi
Starting Member
24 Posts |
Posted - 2011-06-16 : 04:01:16
|
| I have location table which has the details of all available locations.i have Location1 table which has the locations that has the available stocks.Now i have to write a query to find the sum of partly filled locations, Fully filled and empty for a particular whse.Please help me out. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-16 : 04:54:12
|
| How do you know if a warehouse is full? Is the capacity somewhere==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
mkgmahi
Starting Member
24 Posts |
Posted - 2011-06-16 : 05:37:18
|
| Cubiccapacity is present in Location table. And i can find the used capacity by multiplying fields QTY and STDCUBE from LOCATION1 table i.e used capacity for the available stocks |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-06-16 : 08:01:29
|
| Can you please CREATE TABLE statements, insert statements with sample data and what you expect to get out of the query...?- LumbagoMy blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/ |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-16 : 08:06:33
|
| maybe something likewith cte as(select LocationID, used = sum(QTY * STDCUBE)from LOCATION1group by LocationID)select t1.LocationID, available = t1.Cubiccapacity - coalesce(t2.used,0)from Location t1left join cte t2on t1.LocationID = t2.LocationID==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|