.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Subtracting debits from credits when they are all positive numbers and credit/debit is indicated in

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :Sql Server
Hi,   I have a table with four columns - InvoiceCreditLineID, SOPOrderReturnLineID, InvoiceCreditQuantity, SOPInvoiceCreditType. The third contains only positive numbers. The fourth contains a 1 for credits and a 2 for debits.   I need to show summed credit quantities minus the summed debit quantities, grouped by SOPOrderReturnLineID. I tried using a sum in a subselect in the select clause for the credit quantities and another for the debit quantities, but this just shows me the totals for the whole table.   Any idea how I do this?

View Complete Post

More Related Resource Links

Debit v Credit


Hi, Can someone assist me? I am trying to produce a total by month and year for all months for this year and last year even if there are no records present. I also need my second query to be taken from the first query to give me a total of debits v credits.

How do i join the two queries together to get my results?

Query 1








Credit Card Numbers


I didn't know where else to post this, so if this is the wrong area, I apologize.

I have a client who had us build him an e-commerce site tied into paypal.  Well, he is tired of paypal and wants everything centralized.  He has an in store payment processing system that he uses and now would like to use that for his e-commerce store as well.  So he wants to manually enter the credit card numbers into his payment system in the store.  Only problem is I would rather not store credit card numbers on our server.  Does anyone have a solution so that I can securely get him the credit card numbers without storing them somewhere?  He said as long as he can run it once for the sale he is happy.  Any ideas?



Generate Random Numbers

SQL Server has a built-in function that generates a random number, the RAND() mathematical function. The RAND math function returns a random float value from 0 through 1.

Two numbers after dot



How to do this:

10 becames 10.00

12.3 becames 12.30

14.23 becames 14.23

Thanks you

accept numbers only , telephone validation



my requirement is textbox has to accept only numbers and  " ( ) - " symbols only.

any code plz


Add page numbers for paging in data view web part


Hello all,

Has anyone found a solution that will allow me to have page numbers for paging in a data view web part. For instance, if I have 40 items/rows and I set the paging to display 10 items, I'd like the paging to show 1 2 3 4 rather than showing 1-10 and having to click next over and over to get to a specific item.

I found this article, but it is for 2003 and doesn't seem to apply to 2007 or if it does I am not able to really figure out how.


Please help!

Thanks in advance.


Last numbers from a string


I need a vb function to determine the last numerical characters in a string. For example, if the string is Step1, I need it to return 1. If the string is Step32, I need it to return 32.

I'm aware of the string functions like Right, Instr, etc but I'm just not sure how to get what I need. Any suggestions?

get the string of 6 numbers following a dash and a space

I need to retrieve a string of 6 numbers which following a dash and space e.g - "John Smiley - 023112 - California" I would like to get the "023112" part

Help: Rounding off numbers

I'm having some problems when it comes to rounding off numbers. In the reports I build the users wants to see the numbers in M$ or k? . that is Million$ or kilo?. So what I do is take the money and divide it by 1.000.000 or just by 1.000. The thing is that if a number is 750.000 and I divide it by 1.000.000 it should say 0,75M? for example. But nooo, it says 1M?, and that's not right. Any suggestions?  Thanks in advanced

How to skip page numbers?

I have a SSRS (2005) report with multiple subreports inside of it. Page numbers are displayed on the footer of the "outer" report. After one specific subreport, though, the user wants to have space to insert three pages from a different source, so she wants the page number on the footer to be increased by three. I tried a gazillion things, but it seems that the only possible way is to print three empty pages and replace them (what a waste) before distributing the report. Any suggestion?

Prefix in Numbers

how can i determine prefix of numbers in SQL? for example i want to select records that their ids starts with "123".

RegEx for numbers, letters & underscores only

I have this code:public bool IsAlphaNumeric(String strToCheck){  Regex objAlphaNumericPattern=new Regex("[^a-zA-Z0-9]");  return !objAlphaNumericPattern.IsMatch(strToCheck); } how do I modify the Regex to also accept underscores? 

Order the numbers by value

This seems very basic but I can't seem to find a fast way to do it..I have the following numbers:5, 3, 10, 52, 1I want to order them in the correct format from 1 to 52 and be able to point out which one is the highest, which one is the lowest, which one the second to highest, etc.

Count numbers of days (no time table in datasource)

I read the following regarding adding a measure for counting the number of days: The trick is to create new measure group, which will have only one dimension - Time, and a measure with Aggregation Type 'Count' bound to the Day attribute of Time dimension (or any other attribute if we need to count something different from days). The most important setting on this new measure group is to leave IgnoreUnrelatedDimensions=true - this will allow to use this measure across any other dimension in the cube. Howerver, this solution assumes that one has a time dimension based on a table in the datasource. I have a Time dimension that created was by the BIDS wizard that is not in my source database but appearantly invisibly hidden on the AS server without direct access to it. (If I try to add a new measure group (as needed according to the post above) then I can only choose from tables that have nothing to do with time). Can somebody explain how I can do this without a specific timetable in my datasource? Do I need to add a timetable just for this purpose? Can it be stand-alone or do I need to add a relationship with all current tables that have date-columns in them? (I am a finance manager that is building a sales cube based on Navision 3.6, which is already working quite nicely, but still very much a newby)

Subtracting from Strings

I am writing a windows form which requires putting all the words in a textbox in an array. Everything is fine except the backspace function. Obviously, when the user hits backspace, I want it to remove the last character typed; however, I keep getting errors when I subtract from a string... here's the code (it's in c++ but I'm fine if I get code samples in other programming languages from you) it is in a key down event handler for textBox1   if(e->KeyCode != Keys::Space && e->KeyCode != Keys::Back && e->KeyCode != Keys::ShiftKey) { input[j] += e->KeyCode.ToString(); } if(e->KeyCode == Keys::Back) { if(input[j] == "") { j--; } else { String^ theText = input[j]; int i = theText->Length - 1; input[j] = input[j] - theText[1].ToString(); } } if(e->KeyCode == Keys::Space) { j++; } //j is an int and input is a string array  

Javascript numbers only, & format it to Decimal

Hello Experts, I need some help guys ;( I want some javascript code that make sure that end user must enter only numbers on textbox (currency,number), no characters, also typed number will be formated to be decimal number, I mean if user type (22222), javascript should format the number to be (22,222.0) javascript function should be called while end user typing on Textbox. so if he enter character, then the character should be removed automatically. I read many posts that talked about this, but most of them are using the onkeypress(event), so if the user paste the text that code will not work. Please help me guys, I need this urgent

query negative and positive values and not their boolean counterpart

Good Day Need help.. I have this simple table, CREATE TABLE [dbo].[sample] ( [id] [int] NOT NULL , [number] [int] NULL , ) ON [PRIMARY] i wanted to make a select query that would display two columns(positive, negative) the sql statement that i made: "select (sample.number > 0) as positive, (sample.number < 0) as negative from sample " what happened is that, it displays the boolean counterpart and not the value.. I wanted to show this kind of data: substitute the "False" value into 0 and "-1/true" value with the exact absolute numerical value.   |debit||credit| |   0   ||  200 | |   0   ||  57   | |   50 ||  0     |   is this possible?  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend