473,765 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get all order ID which are not paid in SQL Server 2008?

2 New Member
Hi , I want to get all order id numbers for selected customer which not payed till now, my data show as following:



What I want is Write a SELECT statement that answers this question:

Expand|Select|Wrap|Line Numbers
  1. select orderID from order where customer id = @custID and Total cashmovementValue for current order id is less than total (sold quantity * salePrice ) for current order id.
How to do it?

Thanks.
Mar 17 '13 #1
3 2048
r035198x
13,262 MVP
1.) I can't view your picture from where I am.
2.) This is more an SQL question than a C# question.
3.) The query to write depends on your table structure. e.g are the column cashmovementVal ue, sold quantity and salePrice all on the order table?
Mar 18 '13 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code. Your thread has been moved to the SQL Server forum.
Mar 18 '13 #3
swathee
9 New Member
Expand|Select|Wrap|Line Numbers
  1. SELECT O.OrderID
  2. FROM [Order] O
  3. INNER JOIN (
  4.    -- Add up cost per order
  5. SELECT OrderID,
  6. SUM(SoldQuantity * P.SalePrice) AS Total
  7. FROM OrderLine
  8. INNER JOIN Product P ON P.ProductID = OrderLine.ProductID     
  9. GROUP BY OrderID
  10. ) OL ON OL.OrderID = O.OrderID
  11. LEFT JOIN (
  12.     -- Add up total amount paid per order
  13. SELECT OrderID,
  14. SUM(CashMovementValue) AS Total
  15. FROM CashMovement
  16. GROUP BY OrderID
  17. ) C ON C.OrderID = O.OrderID
  18. WHERE O.CustomerID = @custID
  19. AND ( C.OrderID IS NULL OR C.Total < OL.Total )
Dec 9 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3110
by: =?Utf-8?B?T2xpdmllciBNQVRST1Q=?= | last post by:
I'm trying to run an ASP.NET 2.0 web site on Windows Server 2008 RC1. I encounter a server error : HTTP 500.19 - Configuration data is invalid IIS7 claims that the <appSettingssection in web.config is invalid. The management tools are also unable to parse the configuration. The same web site, with the same configuration, is running perfectly on Vista. Is it tied to Windows Server 2008 RC1 ? Any help appreciated.
1
1891
by: =?Utf-8?B?S2luZXRpYyBKdW1wIEFwcGxpZmUgZm9yIC5ORVQg | last post by:
Do want to attend the Microsoft SQL Server 2008 and Visual Studio 2008 sessions at your home PC?. Yes now it is possible. Microsoft has scheduled a Webcasts for you on SQL Server 2008 and Visual Studio 2008 on February 2008.
1
2537
by: =?Utf-8?B?bWFzYWtpeQ==?= | last post by:
Hello, I'm trying to develop 32-bit Windows Native C/C++ application using Visual Studio 2008, on 64-bit Windows Server 2008. Q1. Is it possible to develop 32-bit C/C++ application using VS 2008 on 64-bit Windows Server 2008? Q2. How and What I should arrange the development environment, for developping 32-bit C/C++ application using VS 2008 on 64-bit Windows Server 2008? Q3. I'm trying to use Virual PC for the development, is it...
1
2455
by: Ken Fine | last post by:
I have set up Microsoft Search Server 2008 Express. I want to know how I can query against it and return results in a form that can be bound to ASP.NET controls like ListViews. If there's simply a way to return results as an ArrayList or other data structure I can figure out the rest of this problem myself. What I don't want: * I don't want to deal with XSLT * I don't want to work with prebuilt controls from SharePoint or somesuch. I
1
2234
by: Chris O'C | last post by:
See: http://blogs.zdnet.com/microsoft/?p=1519 "Microsoft officials announced at TechEd South Africa on August 6 that SQL Server 2008 has been released to manufacturing. "Microsoft officials said last month to expect the product on August price lists. SQL Server 2008 is available as of today to MSDN and TechNet subscribers and will be available for evaluation download on Aug. 7, company officials said. SQL Server 2008 Express and SQL...
1
3773
by: =?Utf-8?B?QW50amU=?= | last post by:
I need product keys for Terminal Server Windows Server 2008 access (CALs) under MSDN - TSLM Service said they cannot provide product keys for the access.
6
9254
by: AAaron123 | last post by:
I need to move a database from sql server 2008 to sql express 2008. Will backing up the sql server 2008 database to a file and then using that file to restore to sql express 2008 work? I don't have express on my machine so I can't simply try to see if it works. If I do do it, sql server will be on my machine and sql express will be remote.
2
8107
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts: http://kbalertz.com/954822/install-configure-Indexing-Service-Windows-Server-computer.aspx http://kbalertz.com/820105/Application-Query-Indexing-Service-Catalog-Using-Visual-Basic.aspx I can search some files .xls .doc and others but It will not find anything in .pdf
1
3659
by: BobLewiston | last post by:
I installed SQL Server 2008 Express, basic edition (SQLEXPR32_x86_ENU_Bootstrapper.exe, version 9.0.30729.1) without any problem. Then I attempted to install AdventureWorks Sample Databases for SQL Server 2008 (SQL2008.AdventureWorks_All_Databases.x86.msi). This attempt failed because SQL Server 2008 Express, basic edition doesn’t support Full-text Search, which AdventureWorks requires. So I uninstalled SQL Server 2008 Express, basic...
0
3139
by: IT Couple | last post by:
Hi 1) Question one I'm installing SQL Server 2008 Enterprise Edition on Windowds XP (remotely) and in the 'readme' file it tells me to install SP1 first and then SQL Server 2008 but when I try to download the SP1 http://www.microsoft.com/downloads/details.aspx?FamilyID=66ab3dbb-bf3e-4f46-9559-ccc6a4f9dc19&displaylang=en it says Supported Operating Systems: Windows 7; Windows Server 2003; Windows Server 2008; Windows Vista Doesn't...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.