Question:
SQL server statement help?
?
2013-01-24 00:17:18 UTC
I need help Writing a sql statement here are the details

Write an SQL statement to display the WareHouseID and the sum of QuantityOnHand grouped by WareHouseID. Omit all SKU items that have 3 or more items on hand from the sum, and name the sum TotalItemsOnHandLT3. Show WarehouseId only for warehouses having fewer than 2 SKUs in their TotalItemsOnHandLT3 and display the results in descending order of TotalItemsOnHandLT3
Seven answers:
Mike S
2013-01-24 04:57:36 UTC
supposing thath the table nmae is warehouse , query would be:



select warehouseid,sum(quantityonhand) as TotalItemsOnHandLT3

from warehouse

where quantityonhand<3

group by warehouseid having sum(quantityonhand)<2

order by 2 desc
Serge M
2013-01-24 02:08:21 UTC
Start with



select WareHouseID, sum(QuantityOnHand)

from table

group by WareHouseID



Then

http://www.sql-tutorial.ru/en/book_getting_summarizing_values.html
willame
2016-08-08 11:56:44 UTC
You have got to figure our what variety of information `decimalField` contains. Whether it is speculated to be an integer then you could use decimalField = 0 If it's a string, then you definately have got to quote it decimalField = 'zero' I recommend you take a appear at the constitution of your desk and see what variety of data you've gotten decimalField set to contain. To do what you are attempting to do, be sure it is set to `decimal` or `integer` and no longer `varchar` (which is most of the time the default surroundings) :)
TheMadProfessor
2013-01-24 06:49:36 UTC
Always give some indication of the database schema if you want query help. Otherwise, we'd just be guessing at what you want.
anonymous
2013-01-24 00:35:20 UTC
What's the database model?
?
2013-01-24 00:51:20 UTC
you need to mention the database model
anonymous
2013-01-24 00:51:09 UTC
i am not understanding ur question ..yet first create table warehouse ( wID='char');



BEST REGARDS:

manoj_sharma337@yahoo.com


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...