Quickbook Online API throws Error Parsing query / trying to use CASE statement in SQL query - api

I am trying to get status based to totalamount field.For that I need to use CASE statement like this :
Select TotalAmt,CASE WHEN 'TotalAmt' = '0' THEN 'Open' ELSE NULL END AS status from Invoice
I have checked the syntax too,it's correct.But still I am getting query Parser error

Intuit's flavor of SQL (which is a very limited, slightly non-SQL-standard dialect of SQL) does not support CASE statements.
You can't do what you're trying to do, as it's unsupported.

Related

Hive SQL Select is not working with multiple AND criteria, showing error: The operator 'AND' accepts at least 2 argument

I am trying to run a very simple query that just select all the rows based upon some multiple criteria and all are inclusive i.e. I am using AND in select HiveQL statement. The table is an external table in Hive and the storage handler is phoenix, so I checked in phoenix also about that query and it is working fine, but in Hive, it is showing some java IO exception error which I am not able to get where I am wrong. The query I am using is:
SELECT * FROM msme_api.msme_jk WHERE gender='Male' AND socialcategory='General';
The complete error message is:
Error: java.io.IOException: org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException: The operator 'AND' accepts at least 2 argument. (state=,code=0)
I am trying for external and for internal Hive tables, In both, the issues are still the same but when I give order by, OR statement then it's surprising that it works.
SELECT * FROM msme_api.msme_jk WHERE gender='Male' AND socialcategory='General' order by aid;
SELECT * FROM msme_api.msme_jk WHERE gender='Male' OR socialcategory='General';
Both works fine but with AND, I am getting the error.
I still confused about how hive is taking and processing the above queries and why I am not able to execute simple select statement. Any help will be appreciated.

Identify DBMS from dialect SQL syntax?

I'm working with a third party API for which I have no documentation. There is a method that takes a SQL string and returns a resultset. Based on valid SQL syntax, I want to identify the SQL DBMS vendor, product and version.
Syntax that works as expected as part of a valid SELECT query:
CASE WHEN 1 = 1 THEN 1 ELSE 0 END
CAST('Catatonic' AS CHAR(3))
GETDATE()
CONVERT(VARCHAR(10), GETDATE(), 101))
SELECT TOP 1 valid_column FROM ValidTable
Syntax that causes syntax errors:
COALESCE(NULL, 'Dog')
ISNULL(NULL, 'Dog')
CURRENT_TIMESTAMP
SELECT ##VERSION
SELECT version()
statements terminated by ; (though this could be an API thing)
Any other SQL syntax to try?
My attempt at an answer, given your tests and the comments above:
Tell the 3rd-party that hosts the API, as well as your boss and/or customer, that you cannot work with an API that does not have documentation, and you MUST have further support from the API vendor to perform your work effectively.
If the documentation says "ANSI SQL Compliant", then that is obviously not true, since your tests include various (well thought-out) instances that would seem to suggest SQL Server, but obviously do not support all queries that SQL Server itself would allow.
So, the 3rd party is apparently filtering, re-parsing, or otherwise modifying the SQL you provide to it, and without further information about what that layer is and what it does/doesn't do, you're hands are more or less tied, and your limited to guesswork and trial-and-error.

An 'IN' inside an 'IFF' gives a syntax error

I cannot figure out why this is wrong. The syntax for an IFF is defined here:
https://msdn.microsoft.com/en-us/library/hh213574.aspx
Why does it complain about the IN operator?
It looks like you're using a version of SQL Server that does not support this function (pre SQL Server 2012). An alternative is to use a case statement like so:
Select NEWID(), m.MALEPUNKTYPE,
case when m.MALEPUNKTYPE in ('E17', 'E18') then 'D02' else null end
from AMALD m
This is supported from SQL Server 2005 onwards however it should work on earlier versions too

SQL COMMAND + CASE Crystal Reports

I am having a an issue with SQL Command and CASE. I am pretty new to Crystal Reports/SQL and I have a basic code that I am playing around with to learn. I want to clean out a field -- that has imported from SQL Server. I just want to do something simple like this:
SELECT "I"."I_TYPE", "Alleg” =
CASE
WHEN "ALLEGs"."ALLEG” LIKE ‘*im*’ THEN ‘Improper’
ELSE ‘UNKNOWN’
END
I get an error that says Database Connector Error:
'42000:[MS][SQL..Incorrect syntax near ' . ' . Databse vender code 102.
Can you even use CASE as an IF THEN statement in the SQL Command. I am aware of SQL expressions, but I am trying to pull data to sql command to prevent performance decrease.
I am not sure about crystal report but your query formation don't look correct. It should be
SELECT I.I_TYPE,
CASE WHEN ALLEGs.ALLEG LIKE '%im%' THEN 'Improper' ELSE 'UNKNOWN' END AS 'Alleg'
Rahul, is correct for direct SQL commands to the server.
However sometimes when running Crystal Reports we use VBA within the report to do some data tuning rather than modifying the raw SQL on the fly.
This leaves the raw SQL a known result (verifiable on the SQL Server) and then modify the output in Crystal to fit the end users filtering requirements.
This is not efficient with large result sets but when the results are smaller (under 50k records) we usually have our team go with simple (post filtering) to reduce design and testing time.
This technique works very well with dynamic filters on the option section.
example: [Record Selection]
if {?Select Sales Person} <> "ENT" then
{R0033___P2A.ProjectionSP} = {?Select Sales Person} and {R0033___P2A.FM} >= 0
else
{R0033___P2A.ProjectionSP} > "" and {R0033___P2A.FM} >= 0
Where {?Select Sales Person} is a user selection filter and {R0033___P2A} is a predefined report view or stored procedure.

Invalid Column name error in SSRS 2005

I am having an issue with SSRS 2005. I have a case statement that that works fine in other queries and reports, but errors on the latest report for some reason. I don't believe its an issue with the query rather an issue with reporting services. The error I get is "Query execution failed for data set, invalid column name 'Status'.Has anyone else run into this issue? how did you resolve? The code is below just in case
SELECT Task
, Account_Num
, CASE WHEN DATEDIFF(dd,GETDATE(),Due_Date) < 0
THEN 'Overdue'
WHEN DATEDIFF(dd,GETDATE(),Due_Date) < 3
THEN 'Alert'
ELSE 'Okay'
END AS Status
FROM MyDb
Try square brackets around the reserved word [status]
Sometimes this is due to using an alias. Sometimes, one is not allowed to use the alias and must type out the fully-qualified name.
ourDatabase.ourTable.ourColumnName
This may or may not apply to the OP's situation, however. I have not tried it with the Case statement.