SQL Server :: Query For Available & Ledger Balance

Aug 12, 2010

I have a web page that allows user to make transaction and they are allowed to choose if they want their transaction to be immediately transferred to the payee or for future transfer. I have problem handling future transfer, for an example, I want to transfer $100 to A on 12 August but today is only 09 August. So the amount should be deducted . I decided to make 2 balances; Available and Ledger balances. Available balance is the net balance after doing all the future transfers etc. but for ledger balance is what is available at the point of time. I'm thinking how should I form the query for the SQL statement. Currently, this is what I have. Transfer code = 2 -> future transfer

IF (@TransferCode = '2')
BEGIN
--Insert into the account transaction table first--
INSERT INTO ACCOUNTTRANSACTIONS (AccountTransID, CustID, TransDate, TransType, Reference)
VALUES (@AccTransID,@CustID,@Date,@TransType,@Reference)
IF NOT (@Date = Getdate())
IF (@Withdraw > @BankBal)
BEGIN
INSERT INTO ACCOUNTTRANSITEM (AccountTransItemID, AccountTransID, AccNum, Withdraw, Deposit, status)
VALUES (@AccTransItemID, @AccTransID, @AccNum,@Withdraw,@Deposit, 0)
PRINT 'INSUFFICIENT AMOUNT IN BANK'
SET @ReturnValue = 4
RETURN @ReturnValue
END
ELSE
BEGIN
INSERT INTO ACCOUNTTRANSITEM (AccountTransItemID, AccountTransID, AccNum, Withdraw, Deposit, status)
VALUES (@AccTransItemID, @AccTransID, @AccNum,@Withdraw,@Deposit, 1)
END
ELSE IF (@Date = GETDATE())
BEGIN
IF (@Withdraw > @BankBal)
BEGIN
INSERT INTO ACCOUNTTRANSITEM (AccountTransItemID, AccountTransID, AccNum, Withdraw, Deposit, status)
VALUES (@AccTransItemID, @AccTransID, @AccNum,@Withdraw,@Deposit, 0)
PRINT 'INSUFFICIENT AMOUNT IN BANK'
SET @ReturnValue = 4
RETURN @ReturnValue
END

View 1 Replies


Similar Messages:

SQL Server :: Sum And Show Balance From Two Tables?

Jan 22, 2011

I have two table , how to sum and show balance ...

Table 1
ClientID Amount
001 100
002 200
003 300
001 400
004 500
001 600
004 100

Table 2

ClientID Amount
001 200
002 50
003 100
001 150
004 75
001 25

I need the result set like this Here Table 1 minus Table 2.

ClientID BalanceAmount
001 725
002 150
003 200
004 525

View 7 Replies

Lost Session On Load Balance Server From Http To Https?

Jan 26, 2011

We are currently running an asp.net application with 3.5 framework, using a SQL 2008 back-end. We have found that when we go from http to https we lose our session. Basically you come in on Server01 in http, add an item to your cart go to the secure checkout page (https) and you are now on Serve

View 2 Replies

How To Display Users Account And Balance

Mar 17, 2011

I have just created an extra table named AccountDetails with four columns named AccNo,Balance,Transfer and UserId as foreign key to aspnet_userID primary key. I want to display users account and balance whenever the user successfully loged in.

View 4 Replies

Web Forms :: How To Get Balance Based On Three Tables

Jun 7, 2010

This is Table Stucture..

[Code]....

View 1 Replies

Crystal Reports :: How To Display Opening Balance

Mar 3, 2011

I want to display opening balance in page header of the report.

ex :
opening balance :
aaaaa bb 340 2000.00
item brand qty amt
aaaaa bb 34 340
aaaaa bb 34 340

View 1 Replies

Find The Balance Between Javascript (jQuery) And Code Behind

Jun 3, 2010

How do you currently find the balance between javascript and code behind. I have recently come across some extremely bad (in my eyes) legacy code that lends itself to chaos (someHugeJavafile.js) which contains a lot of the logic used in many of the pages.

Let's say for example that you have a Form that you need to complete.
1. Personal Details
2. Address Information
3. Little bit more about yourself

You don't want to overload the person with all the fields at once, so you decide to split it up into steps.

Do you create separate pages for Personal Details, Address Information and a Little bit more about yourself.
Do you create controls for each and hide and show them on a postback or using some update panel?
Do you use jQuery and do some checking to ensure that the person has completed the required fields for the step and show the new "section" by using .show()?

View 2 Replies

DataSource Controls :: Can't Find Query's / By Right Clicking On Database Created A Query In Server Explorer?

May 17, 2010

By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.

View 10 Replies

C# - Algorithm To Balance Variably-sized Items Into Roughly-balanced Sets?

Aug 26, 2010

I'm seeking an algorithm to split a list of items of varying sizes into "N" number of similarly-sized groups.

Specifically, I'm working on an ASP.NET site in C# where I have a (database-retrieved) list of strings. The strings are of varying lengths. I have a set of columns which need to display the strings. I need an algorithm that will find the most balanced sets (item order is irrelevant) to allow the final columns to be as balanced as possible.

Abstracted Example:

Creating 3 columns.

Items to distribute:

- Item A - height 5
- Item B - height 3
- Item C - height 7
- Item D - height 2
- Item E - height 3

Desired output:

Column 1: Item A, Item D
Column 2: Item C
Column 3: Item B, Item E

View 5 Replies

SQL Server :: Sub Query In Cross Table Query To Create Statistics

Mar 2, 2011

I am trying to create statitics for game downloads and am having dificulty with a sub part of my query. the goup by command is not having the disired result and i think i have been looking at it too long to see what i am doing wrong. [Code]....

At the moment it is producing each result in many rows when only 4 rows should appear. its the download column that is doing it. needs to be sub queried or something to display total in relation to month,gameid,userid.

Month-download-GameID-UserID

1 1
1 1

1 1
1 1

View 2 Replies

SQL Server :: Query Slow In Loading / Trying To Display Query Result?

Feb 1, 2011

I am trying to display this query result in an aspx page.

It is very slow in loading. Here is the query. The inner query inside the outer quesry is the problem.(Please see the underlined part in the query) - (If I remove that part it is very fast.)

select

top 500

--This column is the issue
,Governing_Class=( case when exists (select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.appid and tqc.class_code not in('8742' ,'8810','7380')
order by tqcm.premium_amt desc
)
then ( select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.
appid
order by tqcm.premium_amt desc
)
......... From tables

View 7 Replies

Databases :: Oracle Query Convert To Sql Server Query

Sep 3, 2010

I am a biggner in SQL DB . but i started a complicated and painfull work in SQL SERVER 2008. the problem convert Oracle hierarchical query to SQL query. the query

SELECT DISTINCT
LEVEL LVL,
SCH.NSCHEDULE_SL,
SCH.NSCHEDULE_SL_FM,
SCH.CSHED_CNAME
FROM FA_SCHEDULES SCH
WHERE LEVEL = 1
AND NSCHEDULE_SL_FM IS NULL
AND NBRANCH_SL = 2
CONNECT BY PRIOR SCH.NSCHEDULE_SL_FM = SCH.NSCHEDULE_SL
AND NBRANCH_SL = 2

View 1 Replies

SQL Server :: How To Copy Result Query To Another Query

Nov 4, 2010

i have tow query in one stored procedure

first query and the second one every of them return only value

i want to copy the result of tow values in a new row in new table

as i want to check on this tow values in ado.net

i want to get only this tow values as a row not first and secon query

only a row has result of first and second query results

[Code]....

View 3 Replies

SQL Server :: Select Second Query If First Query Returns Nothing?

Oct 14, 2010

How can I SELECT second if first SELECT returns nothing?

View 8 Replies

Forms Data Controls :: Free High Quality Chart To Show Balance Sheet From Database

Apr 19, 2010

Im using asp.net 2.0 with Visual studio 2005... My requirement is i want to show my balance sheet from MS SQL 2005 database to graphical Chart... so Would u guyz will let me know the best high qulaity chat which support asp.net 2.0 with Visual studio 2005..

View 3 Replies

SQL Server :: Get All Rows From Query A That Are Not In Query B?

Dec 17, 2010

Using sql server 2005.

I have an Query A of fields that returns X number of records.

I create a Query B of same fields that returns X-80 number of records.

I want to find out the 80 records that are in Query A but are not in Query B. what is the syntax for this?

View 4 Replies

SQL Server :: Trying To Get A Query Going In SQL Server But Get Bad/ Errors In The Query?

Nov 8, 2010

Trying to get a query going in SQL server but I get bad/ errors in the query.I have a 2 tables. One is the "Project" table while the other is the "Task" table.Table structure is as follows.

Project table => ProjectID,ProjectName
Task table => TaskID, TaskName,ProjectID,Quarter, Hours

A project can have many task. The ProjectID in Task table is the foreign key which reference the project ID.What I need to do is to SUM all the hours in the Task table and group it by quarter and then group it by ProjectID. Output of the SQL should be in the form of projectID,Quarter, Hours.

View 2 Replies

SQL Server :: Import Data From One Server To Another Server Through Sql Query?

Jan 22, 2011

I want to transfer the data from one server to another by sql query. I want query. I dont know how to write?

View 2 Replies

SQL Server :: Linked Server Query / Error Authentication Failed

Dec 15, 2010

I have the following query that uses a linked server that is on a different VLAN of our network:

[Code]....

It works fine in Query Analyzer but when I put it into Visual Web Developer 2008 Express as a SQL Data Source I get an error:

"OLE DB Provider 'MSDASQL' reported an error. Authentication failed."

View 16 Replies

SQL Server :: How To Terminate A SQL Server Query Within A VB Application

Jul 19, 2010

In order to terminate a SQL Server query within a VB application, we use the Dispose method to close and dispose the database connection. That has been the only way we have found to actually stop a query from running and release the resources.

However, the next time a new connection is created to the same database, we are getting the error "'ObjectDisposedException - Safe Handle has been closed.". It seems like it is always trying to reuse the disposed connection from the connection pool, and it is not reinitializing it. By using a different connection string, we can avoid the error, since now it's not using the connection pool. But there must be a better way to either stop the query or to reinitialize the disposed connection.

View 6 Replies

SQL Server :: How To Use 'like' Query

Dec 31, 2010

is this correct:

select * from tablename where xyz like 'dan%' and like 'bill%'

i want to list entries where xyz is daniel, bill steffen.....

View 1 Replies

SQL Server :: IF ELSE With Sub Query?

Sep 4, 2010

for some reason i am always getting an incorrect syntax error in the following queryI have tried 2 ways to write this query and both failed, Query 1:

[Code]....

Query 2:

[Code]....

View 4 Replies

Looping In SQL Server Query

Aug 4, 2010

consider the follwing table, this table actually shows which id was given a new id

i.e 11 was assigned 13

again 13 was assigned 15

15 was reassigned 17....and so on actually 11,13,15,17,19 represent the same user (hope u understood)

customerId rejoiningId

11 13

13 15

15 17

20 21

17 19

48 50

21 25
i need to loop through all the rows and find the relation that which all ids are interlinked

say the user enters the rejoining id -13,hence the result should come out to be as 11,13,15,17,19


if user enters 21result should be 20,21,25

it takes a bit of looping statements in query that i couldnt figure out

View 7 Replies

SQL Server :: How To Run Completely A Big Query

Jul 18, 2010

i have a big query and many data

when i try to execute this query i got this error

how can i run this query complete?

View 3 Replies

SQL Server Date Query?

Jan 15, 2011

I am new to development and want to know the professional way to deal with dates in SQL Server. In my applications mainly we deal with the DATE datatype and no concern with time part. Also maintaining the format dd/mm/yyyy So for example if I have the table with the following structure.

EmployeeTable
---------------
emp_id int
emp_name varchar(50)
join_date date

and if I want to query "join_date" in between start date and end date and pass the dd/mm/yyyy as stored procedure criteria and want to query.What is the professional way to handle dates? I always convert date in varchar and then do the comparison which I guess is the unprofessional way of doing it.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved