Math Notation In Db?
Dec 1, 2007
I'm not a professional dba or dbd, but I'm proficient in the basics of
database design and sql. I want to create a database of math
definitions, and I'm wondering how one would go about creating a
database that contains mathematical notation (and I'm not just talking
about basic symbols where I could get away with ascii code). I need
to be able to insert a wide variety of mathematical expressions, from
fractions to integrals, into fields (just like you can enter in-line
math symbols in MS Word using equation editor). I have no clue how to
go about this. Is it a matter of developing certain programming
skills/languages? Would such a capabliltiy be proprietary (dbms-
specific)? Is it possible at all? Any help would be appreciated.
Thank you.
View 3 Replies
ADVERTISEMENT
Jan 22, 2008
I've got some values stored in nvachar(255) field stored by mistake as scientific notation (eg 7.5013e+006 instead of 7501301) and I need to convert and update the field with normal entry, not scientific notation. Is there a way to do that?
View 6 Replies
View Related
Jul 23, 2005
HiWe've got some numbers stored as Reals which are returning values inscientific notation that we need rounded down to 3 digits to the rightof the decimal.ie 8.7499999E-2 needs to return 8.75.Round, cast, convert, formatnumber in the dts package all fail.Help!Thanks Moe
View 2 Replies
View Related
Jun 1, 2007
In Reporting Services, is it possible to display a field in Engineering Notation or Scientific notation? I guess can do it by adding a format code, can somebody tell me the format for those notations.
Thanks
View 1 Replies
View Related
Mar 11, 2008
I'm in Visual Studios working on a data flow. I want to add some notes. I open a text box (by typing on the screen).
Why can I only get ONE line of text???? The return key doesn't work.
View 5 Replies
View Related
Jun 23, 2006
I was looking to modify how the INSERT happens with regards to replication only to find my solution in the proc itself. When I edit the proc this is what I am displayed in SQL QA or EM:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER procedure "sp_MSins_dboMEETING" @c1 int,@c2 int,@c3 int,@c4 varchar(250),@c5 datetime,@c6 datetime,@c7 bit,@c8 char(1),@c9 datetime,@c10 bit,@c11 bit,@c12 bit,@c13 datetime,@c14 smallint,@c15 datetime,@c16 smallint,@c17 binary(8),@c18 bit,@c19 bit,@c20 bit,@c21 varchar(1000)
AS
BEGIN
insert into "dbo"."MEETING"(
"MEETING_ID", "MEETING_TYPE_ID", "MEETING_STATUS_ID", "TITLE", "START_DATE", "END_DATE", "PUBLISH_IND", "GROUP_IND", "PUBLISH_DATE", "MY_ADVISORS", "SUBMITTED_IND", "ACTIVE_IND", "CREATE_DATE", "CREATED_BY", "LAST_UPDATE_DATE", "LAST_UPDATED_BY", "DATE_INDEXED", "ON_DEMAND_IND", "NOT_REPORTED_IND", "MAJOR_PROJECT_IND", "MAJOR_PROJECT_COMMENT"
)
values (
@c1, @c2, @c3, @c4, @c5, @c6, @c7, @c8, @c9, @c10, @c11, @c12, @c13, @c14, @c15, @c16, @c17, @c18, @c19, @c20, @c21
)
END
GO
create procedure "sp_MSins_dboMEETING";2 @c1 int,@c2 int,@c3 int,@c4 varchar(250),@c5 datetime,@c6 datetime,@c7 bit,@c8 char(1),@c9 datetime,@c10 bit,@c11 bit,@c12 bit,@c13 datetime,@c14 smallint,@c15 datetime,@c16 smallint,@c17 binary(8),@c18 bit,@c19 bit,@c20 bit,@c21 varchar(1000)
as
if exists ( select * from "dbo"."MEETING"
where "MEETING_ID" = @c1
)
begin
update "dbo"."MEETING" set "MEETING_TYPE_ID" = @c2,"MEETING_STATUS_ID" = @c3,"TITLE" = @c4,"START_DATE" = @c5,"END_DATE" = @c6,"PUBLISH_IND" = @c7,"GROUP_IND" = @c8,"PUBLISH_DATE" = @c9,"MY_ADVISORS" = @c10,"SUBMITTED_IND" = @c11,"ACTIVE_IND" = @c12,"CREATE_DATE" = @c13,"CREATED_BY" = @c14,"LAST_UPDATE_DATE" = @c15,"LAST_UPDATED_BY" = @c16,"DATE_INDEXED" = @c17,"ON_DEMAND_IND" = @c18,"NOT_REPORTED_IND" = @c19,"MAJOR_PROJECT_IND" = @c20,"MAJOR_PROJECT_COMMENT" = @c21
where "MEETING_ID" = @c1
end
else
begin
insert into "dbo"."MEETING" ( "MEETING_ID","MEETING_TYPE_ID","MEETING_STATUS_ID","TITLE","START_DATE","END_DATE","PUBLISH_IND","GROUP_IND","PUBLISH_DATE","MY_ADVISORS","SUBMITTED_IND","ACTIVE_IND","CREATE_DATE","CREATED_BY","LAST_UPDATE_DATE","LAST_UPDATED_BY","DATE_INDEXED","ON_DEMAND_IND","NOT_REPORTED_IND","MAJOR_PROJECT_IND","MAJOR_PROJECT_COMMENT" ) values ( @c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8,@c9,@c10,@c11,@c12 ,@c13,@c14,@c15,@c16,@c17,@c18,@c19,@c20,@c21 )
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Is the second version listed at the bottom like a comment or can it actually get called? I am going to script out all of these procs and save them, and then remove the first version (listed at the top) and the use the second version since it does what I need. I just thought it was interesting to see two stored procedures in a single definition, never seen the "PROC_NAME";2 notation, have you? If so please tell me what it does, is it just a way to create a second version of the procedure in a comment type fashion or is it used another way?
View 1 Replies
View Related
Oct 16, 2013
We sometimes have small values stored in a column with datatype of float like 0.000644470739403048 which is being converted to -5.8E-05. Perhaps that is OK to be stored in the database however I need the value in decimal format to use. (I'm using longitude values in google maps).
is there anything I can do at the database level. I was looking at the properties which is 53 numeric precision and 8 length.
View 8 Replies
View Related
Jul 20, 2005
I'm trying to find a way to format a FLOAT variable into a varchar inSQL Server 2000 but using CAST/CONVERT I can only get scientificnotation i.e. 1e+006 instead of 1000000 which isn't really what Iwanted.Preferably the varchar would display the number to 2 decimal placesbut I'd settle for integers only as this conversion isn't businesscritical and is a nice to have for background information.Casting to MONEY or NUMERIC before converting to a varchar works finefor most cases but of course runs the risk of arithmetic overflow ifthe FLOAT value is too precise for MONEY/NUMERIC to handle. If anyoneknows of an easy way to test whether overflow will occur and thereforeto know not to convert it then that would be an option.I appreciate SQL Server isn't great at formatting and it would be fareasier in the client code but code this is being performed as adescription of a very simple calculation in a trigger, all stored tothe database on the server side so there's no opportunity for clientintervention.Example code:declare @testFloat floatselect @testFloat = 1000000.12select convert(varchar(100),@testFloat) -- gives 1e+006select cast(@testFloat as varchar(100)) -- gives 1e+006select convert(varchar(100),cast(@testFloat as money)) -- gives1000000.12select @testFloat = 12345678905345633453453624453453524.123select convert(varchar(100),cast(@testFloat as money)) -- givesarithmetic overflow errorselect convert(varchar(100),cast(@testFloat as numeric)) -- givesarithmetic overflow errorAny suggestions welcome...CheersDave
View 3 Replies
View Related
Jan 10, 2008
Hi All,
Am I missing something or is there something odd with float data types. i know that float is not the most precise definition but i came across something really odd today.
first let me define the scenario.
this is sql server 2005, standard edition build 3042.
I have a table defined as
CREATE TABLE [dbo].[ASSET](
[Property_Num] [numeric](10, 0) NOT NULL,
[Accrual_Factor_Val] [float] NULL
)
the accrual_factor_val was updated to a value of 0.00005 then the web service failed because the proc returned 5E-05!
i opened the table, and discovered this is the stored value. is this correct?
thoughts and ideas?
thanks for your input!
View 5 Replies
View Related
Jan 29, 2005
SELECT membername, outputval
case when choice = 0 then outputval else null end as outputval
from MyDatabase
group by membername, outputval
how to format outputval:
if outputval < 40000
format outputval as:
5 - 5.78 - 6.9 - 6,778 - 4,567.8 - 12,456.78 - etc.
if outputval >= 40000
format it as a scientific.
View 1 Replies
View Related
Apr 25, 2008
Hi ,
I have one problem regarding format of mixed data columns in excel. I am using this query to retieve data from my excel spreadsheet
Select * from OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;IMEX=1;IHDR=yes;Database=E: est.xls;HDR=YES',
'SELECT * FROM [original$]')
to retrieve data from excel sheet.
I am able to retreive all data (numaric and text) , but for few cells I am getting wrong values.
like this
15106749310-> 1.51067e+010
70400672657-> 7.04007e+010
48110753143-> 4.81108e+010
registry setting are €œtext and 0€³. I am also using IMEX=1 in connection string.
I have numeric and text data both in same column,
eg:
70400503549
70400672657
KF1080420908
KF1260370908
KF1260880908
KF1260960908
Could you please help me to get the correct value from excel .
thanks in advance ,
View 7 Replies
View Related
Dec 13, 2006
in the below sql why is year(classdate) " + " a " + " MONTH(classdate) a math command giving me 2006 - 12 = 167
and not "2006/12" as text? please help me
cmdGetCat = New SqlDataAdapter("SELECT DISTINCT year(classdate) " + " a " + " MONTH(classdate) AS monthcode FROM dbo.classT INNER JOIN dbo.classgiven ON dbo.classT.classcode = dbo.classgiven.classcode WHERE (dbo.classT.discount = '-1') AND (dbo.classT.coned IS NOT NULL) ", conNorthwind)
View 4 Replies
View Related
Nov 18, 2007
How do i update a sql table so that the result cannot be less than zero?for example, lets say I have the column "Number"I have a sql update statement that subtracts 1 from number:"Update oTable SET Number = (Number - 1)"Except that Number cannot be less than zero. Is there a way to do this in sql statement so that I don't have to have a select statement just to check that Number is greater than zero to begin with? Thanks
View 4 Replies
View Related
Oct 26, 2004
Hello everyone:
I have a database for one of my websites, a picture rating site. Anyways, right now there are quicte a few tables, and I was wondering how to give the server a break and was wondering if this was possible:
Basicly I have a members table, and a votes table. Members will rate other users pcitures on a scale of one to ten, then the votes will be inserted into the votes table. The only problem with this is that calcuating all the votes a user has can put a straing on the server. I was wondering if it would be possible to create a math column in the members table that would automaticly figure out the users average and having it stored in a field in the members table, so all I would have to do is query the members average located in the mebers table, rather than tallying all the votes in the votes table for each member.
Hope this makes sense, a tutorial or any suggestions would be great!
Thanks
View 1 Replies
View Related
Feb 2, 2004
I have 2 questions.
1) Lets say we have a table
CREATE TABLE TEST
(
N INT
)
These table have 10 records - the numbers from 1 to 10.
I need 1 query ONLY which will update the table and make it with 100 records - the numbers from 1 to 100.
2) How with 1 query ONLY i have select only the prime numbers
View 4 Replies
View Related
Jan 16, 2006
I have some dates stored in a field named "visit"
In a select they show as the format:
2005-07-28 10:45:00.000
So I need to write a query that will select Visits that are more than 90 days old. I thought it might be something simple like:
Select * from patientVisit where ((getdate())-Visit>90)
But that is pulling all visits not just 90 day old ones.
How do I pull the current date/time and compute the cutoff date time that would be 90 days prior for my selection Where clause?
Thanks
View 3 Replies
View Related
Jun 30, 2006
I need to create a new column where I subtract one column by another.
I've been looking fo that for a while now, can someone explain how to do this?
View 7 Replies
View Related
Mar 31, 2006
Hi,How to find the list of SQL math functions in SQL Server 2005?ThanksKai
View 2 Replies
View Related
Nov 23, 2006
select convert(float,'1.2334e+006')1233400.0select convert(decimal(20,2),'1.2334e+006')Server: Msg 8114, Level 16, State 5, Line 1Error converting data type varchar to numeric.can I set some options arithabort etc to have a workaround to thisproblem?Thanks.
View 3 Replies
View Related
Jul 20, 2005
Hi AllI'm trying to find a math function (if it exists) in SQL Server. If itdoesnt exist, then maybe someone can tell me what its called so I cando a bit more reading on itBasically I want to do this:Parameter Components1 12 23 1, 24 45 1, 46 2, 47 3, 48 89 1, 8and so onI'd like to be able to call a function and it would return true orfalse like sofunctionname(1, 9) = trueso 1 is a component of 9functionname(2, 9) = falseso 2 is not a component of 9functionname(4, 5) = trueso 4 is a component of 5If anyone could tell me if it exists in C#, VB.NET, VB6 or VBScript,I'd appreciate it!Thanks in advanceSam
View 2 Replies
View Related
Jan 9, 2008
Below is my table layout, query, and results. I need to perform some date math to display how much time is elapsed between locations as patients are checked into each care_unit. I believe I could use the unique careunit_key but am not sure how to go about this.
[srm].[CDMAB_CAREUNITS]
[CAREUNIT_KEY] [decimal](37, 0) NOT NULL,
[EPISODE_KEY] [decimal](38, 0) NULL,
[CARE_UNIT] [char](20) NULL,
[ROOM_NO] [char](5) NULL,
[BED_NO] [char](5) NULL,
[DATE_IN] [datetime] NULL,
[TIME_IN] [char](6) NULL
select
cu.careunit_key,
cu.care_unit,
convert(nvarchar,e.ADMISSION_DATE, 101) as Admit_Date,
convert(nvarchar,e.EPISODE_DATE, 101) as Discharge_Date,
convert(nvarchar,cu.date_in,101) as date_in,
substring(cu.time_in, 1,5) as time_in,
convert(nvarchar,cu.date_in,101) +
convert(datetime,substring(cu.time_in, 1,5)) as date_time_in
FROM srm.episodes e
inner join srm.CDMAB_CAREUNITS cu on cu.episode_key = e.episode_key
inner join srm.item_header ih on ih.item_key = e.episode_key
inner join srm.patients p on p.patient_key = ih.logical_parent_key
where e.account_number = '11111777777'
CAREUNIT_KEY
CARE_UNIT
ADMIT_DATE
DISCHARGE_DATE
DATE_IN
TIME_IN
DATE_TIME_IN
1488831
3
12/10/2007
12/11/2007
12/10/2007
3:00
12/10/07 3:00
1498258
S4C
12/10/2007
12/11/2007
12/10/2007
5:54
12/10/07 5:54
1498406
SREC
12/10/2007
12/11/2007
12/10/2007
11:05
12/10/07 11:05
1498472
S6W
12/10/2007
12/11/2007
12/10/2007
12:37
12/10/07 12:37
View 3 Replies
View Related
Apr 19, 2007
Good day all
Does anyone know if there is such a quary that can be written which would add up(or any math functions) a line of cells (on different rows) similar to that of working with a excel document?
If so please steer me towards the correct syntax for this.
Regards
Rob
View 1 Replies
View Related
Mar 12, 2008
Hi,
I have a column coming from DB2. It is the time is stored as 6 decimals of a second. So the value I got coming in is 44846(DT_I8), which needs to be divided by 60 to get minutes (747 minutes remainder 26 seconds). Then divide 747 by 60 to get 12 hours remainder 27 minutes. Thus the time is 12:27:26.
I have got a dervived column doing (DT_R8)(SUBSTRING((DT_WSTR,8)PSCCLOGTIM,1,5)) / 60 but the answer I am getting out is 747.433333. Close, but not close enough. Now I assume my problem has something to do with the Math being done on actual numbers not Time based numbers.
Anyone got any ideas on where I am going wrong and what the expression should look like?
View 11 Replies
View Related
Mar 28, 2007
I have been trying to make a database that counts up and down votes (like eBay ratings or reddit votes). I think (hope) I have got the database design right.
I know that you can perform math functions in SQL, but I want to use two COUNT()s from the same table and subtract one (the down votes) from the other (the up votes).
I have been learning ASP.NET 2.0 and it's going well, but I really need help with this. I asked a question on this forum before and the answers were great and really helpful.
If anyone can help that would be great. Thank you.
Jack.
View 3 Replies
View Related
Nov 19, 2003
I need to perform some division on the results of two alias columns that perform counts in a query. What is the best way to do this?
View 7 Replies
View Related
Jul 20, 2005
The business rule is, the sales manager is commissioned on the avg. numberof appointments set up per salesrep per day during the month.I have 2 tables: The UserLog table records only 1 entry per day per user(salesrep). This will log how many salesreps worked a particular day. Thesecond table logs any appointments set up.UserLog: ID, UserName, EnteredTimeAppointment: ApptID, EnteredTime, ApptDateI figured that, for a given date ranged, I could1. sum the number of appointments2. sum the number of days worked2. sum the salesreps / number of days = avg number of salesreps per day3. number of appointments / avg number of salesreps per day = avg numberof appointments per sales repBut this logic is flawed. If I average out every day and then take anaverage of this daily average, I get a different result. Any ideas on howto best solve this problem?Thanks.
View 7 Replies
View Related
Dec 6, 2007
To set the stage, Tables are set up as such for this question:
-----------
Table: Answers
ID - Integer - Auto
Answer - Integer
QuestionID - Integer - FK from the QuizMaster table
StudentID - Integer - FK from the Students table
Table: QuizMaster
ID - Integer - Auto
Answer - Integer
Table: Students
ID - Integer - Auto
StudentName - Varchar(50)
----------
I would like to have an either a sql statement (1st) or a stored procedure (2nd) that would give me the percent correct for each student on the test.
In Access I could cheat and use this:
Code BlockSELECT Students.StudentName,
Count(Students.StudentName) AS TotalCorrect,
(SELECT Count(QuizMaster.ID) FROM QuizMaster;) AS TotalQuestions,
([TotalCorrect])/([TotalQuestions])*100 AS PercentValue
FROM (Answers INNER JOIN Students
ON Answers.StudentID = Students.ID)
INNER JOIN QuizMaster
ON (Answers.Answer = QuizMaster.Answer)
AND (Answers.QuestionID = QuizMaster.ID)
GROUP BY Students.StudentName
ORDER BY Students.StudentName, PercentValue;
Which is composed of the following...
Code Block
SELECT Students.StudentName,
Count(Students.StudentName) AS TotalCorrect
FROM (Answers INNER JOIN Students
ON Answers.StudentID = Students.ID)
INNER JOIN QuizMaster
ON (Answers.Answer = QuizMaster.Answer)
AND (Answers.QuestionID = QuizMaster.ID)
GROUP BY Students.StudentName;
SELECT Count(QuizMaster.ID) AS TotalQuestions
FROM QuizMaster;
([TotalCorrect])/([TotalQuestions])*100 AS PercentValue
But... that wont fly in SQL Server...What would work without using temp tables?
What would be the EASIEST way to do this?
Another way someone suggested is:
Code BlockCREATE PROCEDURE GetStudentGradeByID @StudentID Integer
AS
BEGIN
DECLARE @TotalQuestionsAsked as Integer;
DECLARE @StudentName as VarChar(50);
DECLARE @QuestionsCorrect as Integer;
DECLARE @PercentCorrect as Float;
set @TotalQuestionsAsked = select COUNT(*)FROM QuizMaster;
set @StudentName = select StudentName from Students where ID = @StudentID;
set @QuestionsCorrect = select count(Answers.ID) from Answers LEFT JOIN QuizMaster on Answers.QuestionID = QuizMaster.ID where StudentID = @StudentID AND QuizMaster.Answer = Answers.Answer;
set @PercentCorrect = (CAST (@QuestionsCorrect AS FLOAT) / CAST (@TotalQuestionsAsked AS FLOAT)) * 100.0;
select @QuestionsCorrect as TotalCorrect, @StudentName as Student, @TotalQuestionsAsked as NumQuestions, @PercentCorrect as CorrectPct;
END
But I need this as a datasource for a datagrid that would show all students etc... so using a parameter isn't really what I want.
So... could a stored procedure work for this?
View 14 Replies
View Related
Jan 29, 2008
hi,
declare @query1 varchar(1000)
declare @query2 varchar(1000)
set @query1 = 'select count(*) from table1'
set @query2 = 'select count(*) from table2'
select @query1 - @query2
basically, i want to show the difference of this 2 select statements.. how do i do it?
thanks in advance!
View 5 Replies
View Related
Oct 2, 2007
The value in the table of one DB is 17869 sq. ft. Now to insert this value in a new table of other database the reporting basis is 1000 i.e I need to do 17869/1000 = 17.8 so I have to take the value as 18. Another thing to be kept in mind is the value in the new table should have leading Zeroes. If the value is 18 it should be displayed as 0000018 ( data type in new table is Varchar(7) and in old table char (9) ). What can be the best way to implement this??
View 8 Replies
View Related
Sep 23, 2007
hi,
how can i make mathematical operations with the DateTime format from thw Sql? -- this is the format 9/6/2007 11:09:00 PM --
how can i substract 30 days from that date and know the resulting one?
if i have two dates, how can i know what number of hours and minutes are between them (if they are fewer than 24), or what number of days and hours and minutes are (if the difference is grater than 24 hours)
please help me, thanks
View 2 Replies
View Related
Jun 17, 2008
Hello,
I have this column of time values:
00:00:03.3592675
00:00:00
00:00:03.8592515
00:00:03.6873820
00:00:03.8436270
00:00:03.3436430
It is in varchar format. I tried converting it to datetime but get an invalid format error message.
How can I sum up these values and average them out?
Thanks!
--PhB
View 1 Replies
View Related
Mar 5, 2008
In reference to this thread:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50392
madhivanan asks for sample table data to avoid using a cursor. I could really use this, so here is the table
CREATE TABLE #T (
FORMULA VARCHAR(15),
ANSWER decimal(15,8)
)
INSERT INTO #T SELECT '1', NULL
INSERT INTO #T SELECT '1.0 + 2', NULL
INSERT INTO #T SELECT '1/2', NULL
INSERT INTO #T SELECT '1/2+2', NULL
INSERT INTO #T SELECT '1/(2+2)',NULL
INSERT INTO #T SELECT '3*7.5', NULL
INSERT INTO #T SELECT '3/2*.6-2', NULL
INSERT INTO #T SELECT '(1-1)', NULL
SELECT * FROM #T
-- RUN THE MATH FUNCTIONS, UPDATE THE TABLE'S ANSWER COLUMN WITH THE ANSWER
SELECT * FROM #T
DROP TABLE #T
I would expect this output:
FORMULA ANSWER
====================
1 NULL
1.0 + 2 NULL
1/2 NULL
1/2+2 NULL
1/(2+2) NULL
3*7.5 NULL
3/2*.6-2 NULL
FORMULA ANSWER
====================
1 1.00000000
1.0 + 2 3.00000000
1/2 0.50000000
1/2+2 2.50000000
1/(2+2) 0.25000000
3*7.5 22.50000000
3/2*.6-2 -1.10000000
(1-1) 0.00000000
Any help appreciated, thanks,
View 9 Replies
View Related
Jan 30, 2006
How do i implement this pseudocode in a SQL stored proc?
In my stored proc, intDS and intSS are the corresponding locally declared variables: @cnt1 and @cnt2 (both are int's).
double intRating = 0;
if (intDS != 0)
intRating = ((intDS - intSS ) / intDS) * 100;
if (intRating < 0)
intRating = 0;
intRating = RoundUpDown(intRating);
The last line should round up or downd the decimal value, if it has decimals, to the next round/whole number... e.g. 28.4352635 to 28.
Thank you!
View 2 Replies
View Related