Excel to SQL - CEILING and Error code 1582 - mysql

I have the following excel formula:
CEILING(F9*6763.85873627538/((F9-1)*400+6763.85873627538),1)
Where F9 is named PROJECTED_QUANTITY in my table sample_size_by_service_id
I have the following SQL query written out:
select
PROJECTED_QUANTITY, ceiling((PROJECTED_QUANTITY*6763.858736275380)/((PROJECTED_QUANTITY - 1)*400+6763.85873627538),1)
FROM sample_size_by_service_id
and I'm getting the following error message:
Error Code: 1582. Incorrect parameter count in the call to native
function 'ceiling' 0.047 sec
Not sure what I'm doing wrong here - I'm a novice to SQL and my hours of googling have had me make sure that my PROJECTED_QUANTITY column is an INTEGER type (it is). I suspected that I am badly badgering the combined operators, but I'm not sure how else to write it.
Appreciate any insight! Thanks!

At the suggestion of user3964075, I removed the second parameter as the mysql syntax for CEILING is CEILING(number), not CEILING(number, significance) as it is in excel. Removing the second parameter resolved the issue - I am no longer getting error code 1582 and am achieving the desired results.

Related

MySQL - Where is the Error in this Query? (Error 1064)

I'm trying to execute the query below but WorkBench keeps complaining about a syntax error (Error 1064). I don't know what the error is because even WorkBench highlights each bracket pair and so I can't say there is a missing bracket. Please help.
SELECT
If(Right(Trim(`tbloldfurniture`.`NotesOnOldness`), 4) = 'susp', Substring(Trim(`tbloldfurniture`.`NotesOnOldness`), 1, Char_Length(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`)) - 1)) ,Substring(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`))))
FROM `tbloldfurniture`;
This is the same query broken into its separate parts to aid readability.
SELECT
If(
Right(Trim(`tbloldfurniture`.`NotesOnOldness`), 4) = 'susp',
Substring(Trim(`tbloldfurniture`.`NotesOnOldness`), 1, Char_Length(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`)) - 1)) ,
Substring(Trim(Lower(`tbloldfurniture`.`NotesOnOldness`)))
)
FROM `tbloldfurniture`;
MySQL's substring() function expects at least two parameters and you're feeding it just one in Substring(Trim(Lower(tbloldfurniture.NotesOnOldness))).
Also, you're probably doing something wrong, as you're deducting 1 from a string in Char_Length(Trim(Lower(tbloldfurniture.NotesOnOldness)) - 1).
And yeah, SQL is notoriously terrible with its error messages. Confusing as heck.
The 1064 error is a syntax error. This means the reason there’s a problem is because MySQL doesn’t understand what you’re asking it to do. Cant see an issue with what you have put tho. If your query attempts to reference information in a database and can’t find it, that could be the issue ?

SSIS derived column error (cast type)

I am trying to sum 2 columns (adjustment due day and expiration day):
DATEADD("dd",(DT_I4)AdjustmentDueDayCode,ExpirationDate)
I keep getting the following error message:
An error occurred while attempting to perform a type cast
SSIS Error Code `DTS_E_INDUCEDTRANSFORMFAILUREONERROR*`
I thought it could be because of nulls so wrote the following:
(DT_I4)AdjustmentDueDayCode > 0 ? (DATEADD("dd",
(DT_I4)AdjustmentDueDayCode,ExpirationDate) : "null"
But still getting the same error, any recommendations?
AdjustmentDueDaycode needs to become type BIGINT.
IE)
DATEADD("dd", CONVERT(BIGINT, (DT_I4)AdjustmentDueDaycode),ExpirationDate)

CDec in Access SQL is not behaving the same as when used from Access VBA

According to MSDN the syntax to convert a number to decimal in VBA is
CDec(expression)
I often use conversion function in access SQL as well. eg Clng, Cint etc...
However when I use CDec I sometime get this error
Compile error:Wrong number of arguments or invalid property assignment
Consider:
In the immediate window
? cdec(round(0.00023,4))
0.0002
? CDec(Round(0.12345678+0.00000001,6))
0.123457
? CDec(Round(0.12345679,6))
0.123457
? CDec(Round(0.12345679,6),10)
This gives the above error (ie as expected as no parameter is allowed)
In a SQL query column
CDec(Round(0.12345678,6))
This gives the above error.
CDec(Round(0.12345678,6),2)
This WORKS and give the answer 0. What does the parameter do!?
CDec(Round(0.12345678,6),2,1)
This gives the above error.
I guess when a function is called from access SQL it is using different code to the one used by VBA. However, I'm stuck and don't understand.
Help!
I'm using MS Access 2013: Build: 15.0.4727.1003 32bit
Harvey
Dennis Wilmar of MS tells, that this is a confirmed bug from Access 2003 - not up to be removed:
Error message when you use the CDec() function in an Access query
The suggested work-around is to wrap CDec in a custom function:
Function NewCDec(MyVal)
NewCDec = CDec(MyVal)
End Function

DB2 query fails in SSRS when generated from expression

I'm attempting to create a shared dataset in SSRS based on a DB2 query. The data source uses the DB2OLEDB provider.
When I enter the query directly as text, it executes correctly:
SELECT BTCH_DT FROM FMSCHEMA.TTRANS_HIST_DETL WHERE REC_NO = 13288604
However, when I click the expression button next to the query window, and enter the following:
="SELECT BTCH_DT FROM FMSCHEMA.TTRANS_HIST_DETL WHERE REC_NO = 13288604"
the query fails with
ILLEGAL SYMBOL "=?<ERR_STMT> <WNG_STMT> GET SQL SAVEPOINT HOLD FREE ASSOCIATE". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: SQLSTATE: 42601, SQLCODE: -104
it appears as if SSRS is trying to pass the expression itself to the DB2OLEDB provider instead of evaluating the expression and passing the results of that evaluation.
I've already checked out IBM's site:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/rsql0100.htm but the information provided for SQSLSTATE 42601 wasn't very helpful: "A character, token, or clause is invalid or missing."
Can anyone shed some light on this? Or point me in the right direction? Thanks!

SQLServer Spatial query is returning error An expression of non-boolean type specified in a context where a condition is expected, near ')'

I am trying to learn how to do radius search on records using the new SqlServer 2008 managed spacial type and methods (geography) for doing geospatial calculations. I am following the samples on this web page:
http://msdn.microsoft.com/en-us/magazine/dd434647.aspx
I am specifically trying to do this sample:
-- or declare POINT for "downtown Seattle"
-- 1609.344 meters per mile
DECLARE #Seattle geography = 'POLYGON(....)'; SELECT c.customerid FROM
customer c WHERE c.geog.STIntersects(#Seattle.STBuffer(10 * 1609.344));
However, even before running the query (or when I run the quer--both compile and runtime error)I am getting the following error message:
An expression of non-boolean type specified in a context where a condition is expected, near ')'
I am really baffled by this. I am not doing exactly the same query (I am using my own data with a geography column) but it is almost identical to the sample. I am running Sql SErver 2008 SP2 Standard Edition 64-bit. When I type the query it uses intellisense for the STIntersection method and shows a (other_geography geography) sample so it knows that the method exists. I am properly closing the parentheses and delimiting the expression with a semi-colon but I cannot figure out why I am getting the error. Googling has not worked.
Any thoughts?
Seth
STIntersects returns 0 or 1. Try this:
WHERE c.geog.STIntersects(#Seattle.STBuffer(10 * 1609.344)) = 1