Check For Positive Value
Oct 31, 2007
I need to be able to check & display people who have a positive value in the bills.
i.e > 1p.
On the billingtotal table i need to sum > 1p.
CREATE PROCEDURE rpt_PositiveAccountBalances
(@cmb1 as varchar(100)) WITH ENCRYPTION
AS
BEGIN
SELECT DISTINCT
Site.siteName,
Child.surname + ', ' + Child.forename AS ChildsName,
billPayer.surname + ', ' + billPayer.forename AS BillPayerName,
BillingTotal.total
FROM
Site
INNER JOIN
Child
ON
Site.siteID = Child.siteID
INNER JOIN
BillingTotal
ON
Site.siteID = BillingTotal.siteID
CROSS JOIN
billPayer
WHERE
site.sitename=@cmb1
END
View 3 Replies
ADVERTISEMENT
Nov 6, 2007
I have the following query
OutPut:
ChildName BillPayerName Cost
Mary Fred £50
Total Balance Blank
The problem is when I check for a value > 00.1 in the having clause the total balance column disappears.
But its ok if I use any other comparison operator.
I.e < 00.1.
Any ideas.
create procedure Rpt_pos1 --(@cmb1 as varchar(50)) with ENCRYPTION as
--declare @startdate smalldatetime
AS
set dateformat ymd
set datefirst 7
--loop through weeks
create table #getTable (thesite integer null,thechild integer null,cost money null)
insert #getTable select s.siteid,c.childid,0
from site s,child c
where --s.siteName=@cmb1
c.siteID=s.siteID
and c.active=1
and c.potential=0
insert #getTable
select s.siteid,c.childid,isnull(sum(round(bt.total,2,2)),0)*-1
from site s,child c,billingTotal bt
where --s.siteName=@cmb1
s.siteID=bt.siteid
and c.siteID=s.siteID
and bt.siteID=s.siteID
and bt.childid=c.childid
and c.active=1
and c.potential=0
group by s.siteID,c.childid
insert #getTable select s.siteid,c.childid,isnull(sum(round(p.amount,2,2)),0)
from site s,child c,payment p
where --s.siteName=@cmb1
p.siteID=s.siteid
and c.siteID=s.siteID
and p.childID=c.childID
and c.active=1
and c.potential=0
group by s.siteID,c.childid
create table #results (ChildName varchar(200) null,BillPayerName varchar(200) null, Cost varchar(20) null)
insert
#results
select c.forename + ' ' + c.surname
,case b.telhome when '' then b.Forename + ' ' + b.Surname
else b.Forename + ' ' + b.Surname + ' (' + b.telhome + ')' end
,case when sum(round(g.cost,2,2)) < 0 then cu.Symbol + cast(sum(round(g.cost,2,2)) as varchar(15))
when sum(round(g.cost,2,2)) > 0 then cu.Symbol + cast(sum(round(g.cost,2,2)) as varchar(15))
when sum(round(g.cost,2,2)) = 0 then cu.Symbol + cast(sum(round(g.cost,2,2)) as varchar(15)) end
from
#gettable g
,child c
,billpayer b
,currency cu
,site s
where
cu.currencyid=s.currency
and s.siteID=c.siteID
and c.siteID=g.thesite
and c.childID=g.thechild
and b.billpayerID=c.billPayerID
group by
c.forename,
c.surname,
b.telhome,
b.surname,
b.forename,
c.siteID,
cu.symbol
having sum(round(g.cost,2,2)) > 00.1
order by
c.surname asc
insert #results
select '','',''
insert #results
select
'Total Balance'
,''
,c.Symbol + cast(sum(round(g.cost,2,2)) as varchar(15))
from
#gettable g
,site s
,currency c
where
g.thesite=s.siteid
and c.currencyID=s.currency
group by
c.symbol
having sum(round(g.cost,2,2)) > 00.1
drop table #gettable
select * from #results
drop table #results
go
View 4 Replies
View Related
Mar 30, 2004
Hey guys,
I have a very peculiar issue going on. I have a table that contains a decimal(18,2) column called "Amount". Looking at this table through Enterprise Mgr, I can see that there are values in there that are negative. However, when I run a query in Query Analyzer, it displays all the negative values as positives.
The only workaround I've found right now is to change the column type to "real" and then change it back to decimal(18,2), and it starts showing the negatives as negative. However, without performing this absurd workaround, it doesn't work.
Is there a known bug in QA that would manifest itself as this? What is the cause for this?
Thanks in advance.
View 4 Replies
View Related
Apr 2, 2008
one value should be always positive in report
I just replace "-" to " " using Replace(Fields!sumamount.Value,"-","") and format is currency like $ 1234.12
but after replace I get 1234.1200 in report
format of cell is currency like $ 1234.12 and if I don't use replace - it's ok
how to remove two last zero and add "$" ? or may be other ideas how to show alway positive value ?
View 6 Replies
View Related
Apr 25, 2008
Hi,
I have table with a column which has both negative and positive values.
I want to calculate the sum of positve values and the sum of negative values from that column separately. Is it possible.
Plase help me.
Ex: My Input Values are
column1
-186.5499257
-141.8985222
-95.3846883
-71.1359768
-69.39071172
30.44750844
40.33666032
53.81527872
98.2967252
112.948667
OutPut goes like This
Column1 Column2
-186.5499257 null
-141.8985222 null
-95.3846883 null
-71.1359768 null
-69.39071172 -564.36
30.44750844 null
40.33666032 null
53.81527872 null
98.2967252 null
112.948667 335.84
View 5 Replies
View Related
Jan 18, 2008
I was just wondering if there is a way of converting a number from negative to positive within Reporting Services, ie remove the "-" sign from the front of the number? One of the columns within my report contains a calculation which results in an integer, but it is always a negative number, even though it should really be positive (it would take too long to describe the exact reason for this, but it's to do with the underlying database, which I don't have access to anyway). When I right-click on the relevant cell within the table in Layout view in the Report Designer and go to Expression, there is a list of Conversion functions under the "Common Functions" heading but I can't find anything there which would convert a number from negative to positive. Does anyone know how this can be achieved?
View 5 Replies
View Related
Feb 5, 2007
I want to convert a positive value to a negative value.
How do I do it...
View 3 Replies
View Related
Mar 20, 2014
I have a query that brings in a result from a table that I have to display as a negative, so I use ABS (tbname.fieldname) *-1
This works fine. (Learnt it here from a previous post.)
I have another query that brings in a result from the same table but as a postive. So that works fine too.
Now, I need to sum them together in a new query. If the total value is a positive, fine. If the total value is a negative, it displays as a positive.
My question. Is it actually possible to achieve what I'm trying to do?
Output example below - narrow result for testing.
idpt2 Value2SumQty
N1141307-80970 3.80 2
N1141S2G00009D070 26.16 2
The 3.80 is correct, it is a positive.
The 26.16 is incorrect as it is the output from sum 235.44 -261.6 so I need it to display as -26.6
View 9 Replies
View Related
Oct 11, 2005
Ok, I have a table with IP addresses stored in decimal format using both positive and negative numbers.
The way that they are stored is:
Positve
1 thru 2147483647 = 0.0.0.1 - 127.255.255.255
Negative
-2147483648 thru -1 = 128.0.0.0 - 255.255.255.255
Conversion
positive
x/2^24 . (x/2^24)/2^16 . etc . etc
negative
(x+2^32)/2^24 . ((x+2^32)/2^24)/2^16 . etc . etc
I have a script which works by using UNION and the WHERE statements are x>0 x<0
My problem is I need to use a 3rd party app to run the script (McAfee ePO). McAfee does not recognize the UNION. My question is, can I acheive the same results as the script below, without using UNION.
SELECT ReportFullPathNode.FullPathName,
cast(cast(IPSubnetMask.IP_Start as bigint)/16777216 as varchar) + '.' +
cast(cast(IPSubnetMask.IP_Start as bigint)%16777216/65536 as varchar) + '.' +
cast(cast(IPSubnetMask.IP_Start as bigint)%16777216%65536/256 as varchar) + '.' +
cast(cast(IPSubnetMask.IP_Start as bigint)%16777216%65536%256 as varchar),
cast(cast(IPSubnetMask.IP_End as bigint)/16777216 as varchar) + '.' +
cast(cast(IPSubnetMask.IP_End as bigint)%16777216/65536 as varchar) + '.' +
cast(cast(IPSubnetMask.IP_End as bigint)%16777216%65536/256 as varchar) + '.' +
cast(cast(IPSubnetMask.IP_End as bigint)%16777216%65536%256 as varchar),
cast(IPSubnetMask.LeftMostBits as varchar),
IPSubnetMask.IP_Start
FROM IPSubnetMask, ReportFullPathNode ReportFullPathNode
WHERE IPSubnetMask.IP_Start>0 and IPSubnetMask.ParentID = ReportFullPathNode.LowestNodeID
UNION ALL
SELECT ReportFullPathNode.FullPathName,
cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)/16777216 as varchar) + '.' +
cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)%16777216/65536 as varchar) + '.' +
cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)%16777216%65536/256 as varchar) + '.' +
cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)%16777216%65536%256 as varchar),
cast(cast(4294967296+IPSubnetMask.IP_End as bigint)/16777216 as varchar) + '.' +
cast(cast(4294967296+IPSubnetMask.IP_End as bigint)%16777216/65536 as varchar) + '.' +
cast(cast(4294967296+IPSubnetMask.IP_End as bigint)%16777216%65536/256 as varchar) + '.' +
cast(cast(4294967296+IPSubnetMask.IP_End as bigint)%16777216%65536%256 as varchar),
cast(IPSubnetMask.LeftMostBits as varchar),
IPSubnetMask.IP_Start+4294967296
FROM IPSubnetMask, ReportFullPathNode ReportFullPathNode
WHERE IPSubnetMask.IP_Start<0 and IPSubnetMask.ParentID = ReportFullPathNode.LowestNodeID
View 2 Replies
View Related
Jul 27, 2007
I've a stacked column chart (vertical) both with positive and negative value.
I want an horizontal line only for the value = 0.
I tried to add a serie and to plot it as line, but I see it in the legend and I don't want to see it.
Can I show the gridlines only for the value 0?
Simona
View 1 Replies
View Related
May 7, 2008
Sorry if this question has been answered before--i tried a search but nothing came close to what i needed.
I have a report I am creating where I need to group on whether a number is positive or negative. The number will never be zero. This number is a decimal (currency), if that makes a difference.
I have tried creating a formula field with the following expression:
Code Snippet
IIf(Fields!Num.Value > 0, 1, 0)
I tried creating a group using this field (essentially, positive = 1 and negative = 0), but it gave me no results at all.
If you need any more information, please let me know and I will provide what I can. Thanks for your answers!
View 3 Replies
View Related
Feb 3, 2012
How do I count the number of positive dollar values in a query? I have various negative and positive dollar values and want to count how many positive I have then I will know how many are negative. I cannot put >0 or >0.00 in the where because it still returns everything cuz the programmer set the datatype to be money
View 4 Replies
View Related
Oct 29, 2007
I have a table that displays a bunch of data based on their percentage changes.
There is a parameter (let's say 5%) that the user can set to display only the data which either increased more than 5% or decreased more than 5%.
I want to have a space between the positive changes and the negative changes. ie, to create a blank row between the +'s and the -'s. Does anyone know of a way to do this?
Thanks,
Steven
View 3 Replies
View Related
Jan 6, 2015
I am doing some analysis on our customer base and their payment profiles. I have generated two profile strings, one for whether the balance of an account has gone up or down and one for the size of the balance in relation to the normal invoice amount for the customer. So (for example) the balance movement string will look like this:
UUUDUUUDUUUD-D00 Where U = Up, D = Down, - = no change and 0 = no change and no balance
I want to analyse these strings in two ways. The first is that I want to find customers with a similar pattern: in the example below the first and last patterns are the same, just one out of sync but should be considered the same
Movement Multiple CountRecords
UUUDUUUDUUUD1230123012301175
------------0000000000001163
UDUUUDUUUDUU3012301230121082
The second type of analysis is to find customers whose pattern has changed: in the examples above the patterns are repeated and therefore 'normal' in the records below the patterns have changed in that the first part does not match the second part.
Movement Multiple CountRecords
UUDUUUDUUUUU-----------07
UDUUUDUUUUUU------------7
good way to approach this without either a cursor or a hidden REBAR. The challenge as I see it is that I have to interrogate every string to find out if there is a repeating pattern and if so where it starts and how long it is (heuristic because some strings will start with a repeating pattern and then the pattern may change or deteriorate) and then compare the string for N groups of repeating characters to see if and when it changes and I can't think of an efficient method to do this in SQL because it is not a set based operation.
View 9 Replies
View Related
Sep 18, 2015
MS SQL Server 2008 R2
I have both positive and negative values in a single column, where I want sum total of positive values & negative values. Is there any Expression for this to sort out.
View 8 Replies
View Related
Aug 7, 2015
I have a requirement to use DateDiff(Months,DateTime1,DateTime2) and this must return positive integer values.
Currently negative numbers are being returned because DateTime1 < DateTime2  or DateTime1 > DateTime2 .
The DateTime1 and  DateTime2  values are dynamic and either of them can be bigger than the other.
Any query solution so that always positive value is returned.
View 3 Replies
View Related
May 27, 2015
I have a 2012 report builder chart that has two series (one area chart and one bar chart) combined into one chart. The problem I'm having is the bar chart has much smaller numbers than the area chart and the scaling is messed up.
Is there any way to put the bar chart on the right axis and keep the area chart on the left axis? My goal is to increase the size of the bar chart in relation to the area chart.
Also, is there any way to make the bar chart color red if the number is negative and green if it is positive?
View 4 Replies
View Related
May 20, 2015
I have multiple ODBC connection and how to check all connection automatically during routine check by using batch file.
View 5 Replies
View Related
Jul 20, 2005
Why does M$ Query Analyzer display all numbers as positive, no matterwhether they are truly positive or negative ?I am having to cast each column to varchar to find out if there areany negative numbers being hidden from me :(I tried checking Tools/Options/Connections/Use Regional Settings bothon and off, stopping and restarting M$ Query Analyer in betwixt, butno improvement.Am I missing some other option somewhere ?
View 7 Replies
View Related
Mar 10, 2008
Hello World,
I'm new to SSIS and would like a little assistance getting started, if possible...
Here is what I want to do:
Check if file exist (C:DTS UpgradeFilexxx.txt) --->
Archive file (C:DTS UpgradeArchive) --->
Check if file has data (true or false)
AND/OR
If there are any good website that have good direction, let me know
Thanks in advance for your help!!!
View 5 Replies
View Related
Jun 6, 2008
I need a job run page to fire a job on a sql server if the job is not already running. How do I check if the job is running on the MSSQL server.
Can I use the sp_job_help as it does return 4 data sets with the first having the data I need, but as yet I have not mastered a multi data set return.
View 3 Replies
View Related
Jan 23, 2004
How can I make sure that I have SQL Server 2000 sp3 or sp3a installed?
Thanks you,
View 4 Replies
View Related
Aug 9, 2004
http://thelushed.com/forum/showthread.php?t=138
View 1 Replies
View Related
May 4, 2004
DECLARE @Temp int
DECLARE @FullQry varchar(50)
set @FullQry='select @Temp=Emp_ID from Employee where.....'
Exec(@FullQry)
select @@ROWCOUNT
My Employee table has 3 records and this query sholud return me @@ROWCOUNT=1
but it will return 0 why this i am not able to find out.Exec function return ROWCOUNT or not?
View 1 Replies
View Related
Jun 24, 2008
insert into OPENROWSET('Excel 8.0;Database=D: esting.xls;',
'SELECT * FROM [testing$]')
getting errore
Incorrect syntax near ')'.
View 2 Replies
View Related
Feb 1, 2007
Hi,
Is there any way to tell me how many users connecting to specific database / who are using it in the management studio? we are use the windows authentication mode.
Thanks!
View 1 Replies
View Related
Jan 30, 2008
I want to built a table to a form....
I have some check boxes in this form....
what is the script line for this check box ?
I know it is suppose to work 1 or 0 ? for false or true .....
How I suppose to do this ?
View 1 Replies
View Related
Sep 1, 2006
Hello,I Have a code:<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" InsertCommand="INSERT INTO [shop_clients] ([ID], [IMIE]) VALUES (@ID, @IMIE)"> <InsertParameters> <asp:Parameter Name="ID" Type="Int32" /> <asp:Parameter Name="IMIE" Type="String" /> </InsertParameters> </asp:SqlDataSource> SO this code It will allow me insert to database SQL textbox - name ?If yes How I can:If I click the button My textbox - name, insert to databasePlease me help :)
View 1 Replies
View Related
Nov 25, 2006
Aperently I could not insert a text field to another table from INSERTED in a trigger.It seems th follwoing is working, do you see any problem joining INSERTED to the mySrcTable which is the table that has this trigger
INSERT INTO myRemoteDatabase.dbo.myDestTable (myTrID,myFirstName,myBigText) SELECT i.myTrID, i.myFirstName, p.myBigText FROM INSERTED i INNER JOIN mySrcTable p ON i.myTrID = p.myTrID WHERE (i.myTrType = 'In') Thanks,
View 1 Replies
View Related
Mar 28, 2007
Hi I was wodering how to add an OR statment right in the Check Constraint expression.
This is what I am starting with in the database
([zip] like '[0-9][0-9][0-9][0-9][0-9]')
and what I want well not exact but this would answer my question
([zip] like '[0-9][0-9][0-9][0-9][0-9] || [A-Z][A-Z][A-Z][A-Z][A-Z]')
Thanks for any help
View 5 Replies
View Related
Jul 6, 2007
Hi,
I have two web pages in one web page i have 5 check boxes. For example if the user checks the Checkbox1, checkbox2 and clicks on button.
On the button click I am storing the selected checkboxes value in database lke the following:
Year Options
xxx 1
xxx 2
in the above format( user selectes checbox1, check box 2).
And in the Second Web page I am showing the 5 checkboxes but in this web page I need to check the first and second checkboxes on the page load because user selectes those two check boxes in the first web page.
my select query returning the results like this:
Options
1
2
based on options I have to check those corresponding check boxes in the second web page.
How to achive this.
Thanks in advance
View 2 Replies
View Related
Aug 6, 2007
I have a pretty standard form that inserts users name, office, and team. It generates a random 10 digit ID for them. How would i got about checking the table to make sure that ID doesn't exist?
Here's my insert code.
string strConnection = ConfigurationManager.ConnectionStrings["TimeAccountingConnectionString"].ConnectionString; SqlConnection myConnection = new SqlConnection(strConnection);
string usercode = GenPassWithCap(9);
String insertCmd = "INSERT into users (ID, firstname, lastname, office, team) values (@id, @firstname, @lastname, @office, @team)"; SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.VarChar, 10)); myCommand.Parameters["@id"].Value = usercode;
myCommand.Parameters.Add(new SqlParameter("@firstname", SqlDbType.VarChar, 50)); myCommand.Parameters["@firstname"].Value = txtFirstName.Text;
myCommand.Parameters.Add(new SqlParameter("@lastname", SqlDbType.VarChar, 50)); myCommand.Parameters["@lastname"].Value = txtLastName.Text;
myCommand.Parameters.Add(new SqlParameter("@office", SqlDbType.VarChar, 75)); myCommand.Parameters["@office"].Value = dwnOffice.SelectedValue;
myCommand.Parameters.Add(new SqlParameter("@team", SqlDbType.VarChar, 20)); myCommand.Parameters["@team"].Value = dwnTeam.SelectedValue;
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
Do I run a completey different select command before hand and try to match that field?
View 1 Replies
View Related
Jan 29, 2008
Hi,
I'm trying to populate a table in one database with details from a identical table in another database. How do I check to see if the row exsits before I insert the data because at the moment I'm getting a violation of a primary key error.my codes something like the below
insert into db2.table1(values)
select *
from db1.table1, db1.table2 where t1.id = t2.id
Cheers Dave
View 9 Replies
View Related