Solved

While loop in sql

Posted on 2013-01-25
2
370 Views
Last Modified: 2013-01-25
Hi. I have following task.
1) Find number of orders for the different shipping fee.
The result should be like:
ShippingFee:      OrderCount:
70                        150
90                         140

And so on.

I was thinking abount a while loop in sql, but don´t know how:

while (select distinct shippingfee from orders)
(
select count(orderid) from orders where shippingfee = shippingfee
)
Can somebody help me?
0
Comment
Question by:bongii
2 Comments
 
LVL 17

Accepted Solution

by:
aflockhart earned 500 total points
Comment Utility
select
shippingfee,count(orderid)
FROM orders
GROUP BY shippingfee
0
 

Author Closing Comment

by:bongii
Comment Utility
Nice :=)
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now