Cannot run the query as it says "unable to execute query, invalid operation or syntax using multi-valued field" in Access - sql

SELECT
tbl_facilityinformation.exportid,
qry_numberofpatientsgreaterthan12withdepressionscreen.numberofuniquepatientsagegreaterthan12withdepressionscreening AS NumberUniquePatientsWithDepressionScreening,
qry_numberofuniquepersonsgreaterthan12years.numberofuniquepersonsgreaterthan12years,
[qry_numberofpatientsgreaterthan12withdepressionscreen]![numberofuniquepatientsagegreaterthan12withdepressionscreening] /
[qry_numberofuniquepersonsgreaterthan12years]![numberofuniquepersonsgreaterthan12years] AS PercentageOfPatientsGreaterThan12WithDepressionScreen
FROM
(
tbl_facilityinformation INNER JOIN qry_numberofpatientsgreaterthan12withdepressionscreen ON
tbl_facilityinformation.exportid = qry_numberofpatientsgreaterthan12withdepressionscreen.exportid
)
INNER JOIN qry_numberofuniquepersonsgreaterthan12years ON
tbl_facilityinformation.exportid = qry_numberofuniquepersonsgreaterthan12years.exportid
GROUP BY
tbl_facilityinformation.exportid,
qry_numberofpatientsgreaterthan12withdepressionscreen.numberofuniquepatientsagegreaterthan12withdepressionscreening,
qry_numberofuniquepersonsgreaterthan12years.numberofuniquepersonsgreaterthan12years;
I dont understand why I'm getting the error:
Unable to execute query, invalid operation or syntax using multi-valued field.
I have tried to look for syntax errors but could not find any.

Related

SSRS Dataset Query - An expression of non-boolean type specified in a context where a condition is expected, near ','

I am attempting to correlate two databases together with the following query:
SELECT AE.EventTimeStamp, AE.SourceName, AE.Message, AE.Severity, AE.GroupPath
FROM FTAE_History.dbo.AllEvent AE
JOIN BatchHistoryEx.dbo.SequenceActiveUnit ActiveUnits
ON #RecipeName = ActiveUnits.SequenceName
AND ActiveUnits.ActiveUnit like (CONCAT('%',RIGHT(AE.GroupPath,CHARINDEX('.',REVERSE(AE.GroupPath))-1),'%'))
WHERE AE.EventTimeStamp between #StartTime_UTC and #EndTime_UTC
AND LEN(AE.GroupPath) > 13
AND AE.Active = 1
AND AE.Severity >= 500
ORDER BY EventTimeStamp
When run in SQL Management Studio, I can execute on any #RecipeName or #StartTime_UTC/#EndTime_UTC. When I embed this query in an SSRS dataset, some #RecipeName's or times throw this error:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'GetUniqueID_BatchIDForAlarms'. (rsErrorExecutingCommand)
An expression of non-boolean type specified in a context where a condition is expected, near ','.
The error is happening inside the JOIN statement - when I remove that block all possible parameters entered execute even in SSRS. What is causing the difference? How best do I implement an error handling system to allow this query to execute without exceptions?

Problematic syntax error near ")" at line 14: SQL statement - SAP Hana

I am sure that you are used to this question but nonetheless I am having trouble with my SQL script. It is very frustrating.
When I execute the SQL against the SAP Hana database, I continuously receive this error:
Errors occurred while executing the SQL statement: SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near ")": line 14 col 35
Let me present the SQL concerned here:
SELECT
BKPF.BKTXT, BKPF.MONAT, BSEG.BELNR, BSEG.BUKRS, BSEG.DMBTR, BSEG.GJAHR, BSEG.MANDT, BSEG.PRCTR, BSEG.SAKNR, CEPCT.KTEXT, CEPCT.LTEXT, SKAT.MCOD1, SKAT.TXT20, SKAT.TXT50
FROM
SAPPR1.BSEG
INNER JOIN SAPPR1.BKPF ON BSEG.GJAHR = BKPF.GJAHR
INNER JOIN SAPPR1.CEPCT ON BSEG.PRCTR = CEPCT.PRCTR
INNER JOIN (SELECT
SAKNR, TXT20, TXT50, MCOD1
FROM
SAPPR1.SKAT
WHERE
SPRAS not LIKE '%[a-z0-9 .]%' ) AS SKAT_SUB ON BSEG.SAKNR = SKAT_SUB.SAKNR
WHERE
BKPF.MONAT = (SELECT Month('?')-1)
AND (BSEG.GJAHR = (SELECT Year('?')-1 HAVING Month('?')-1 < 4) OR BSEG.GJAHR = (SELECT Year('?') HAVING Month('?')-1 > 3))
AND BSEG.MANDT = ?
;
Unlike other DBMS HANA does not support selecting records out of nothing.
A SELECT without a FROM is not valid.
In order to create a single-row set one can use the DUMMY table.
SELECT current_date FROM DUMMY;
creates the single-row set with the result of the function expression.
Having said that, for comparisons a set is not required. Instead the function can be directly put into the expression:
WHERE
BKPF.MONAT = (MONTH(?)-1)
Also note that for string typed bind variables no quotation marks are required or allowed.

Syntax Error: ON RIGHT when trying to match a substring in Impala

Does anyone know why I am receiving this error? I am using SQL in IMPALA and it wont run. Theres a yellow underline under mem_register_hsty_view and transparency_services_summary_2018.
Here is my code:
use sndbx_dx;
SELECT
r.member_identifier,
n.fst_nme
FROM mem_register_hsty_view n
JOIN transparency_services_summary_2018 r
ON RIGHT(TRIM(r.member_identifier),4) = LEFT(n.fst_nme,4)
ORDER BY
r.id_key,
r.group_number,
n.fst_nme;
Here is the error:
AnalysisException: Syntax error in line 1:undefined: ...ervices_summary_2018 r ON RIGHT(TRIM(r.member_identifi... ^ Encountered: RIGHT Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, REPLACE, TRUNCATE, TRUE, IDENTIFIER CAUSED BY: Exception: Syntax error
From the current Impala documentation the functions for taking some number of characters from the left or right of the string appear to actually be STRLEFT and STRRIGHT, respectively. Apply this to your current query gives:
SELECT
r.member_identifier,
n.fst_nme
FROM mem_register_hsty_view n
INNER JOIN transparency_services_summary_2018 r
ON STRRIGHT(TRIM(r.member_identifier), 4) = STRLEFT(n.fst_nme, 4)
ORDER BY
r.id_key,
r.group_number,
n.fst_nme;

Error while trying to save a product in magento

Whenever I am trying to make any change in a product and save it in magento backend I am getting the following error.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) AND (p.entity_id = '1696') LIMIT 1' at line 3, query was: SELECT DISTINCT p.entity_id FROM `catalog_product_entity` AS `p` INNER JOIN `catalog_product_flat_1` AS `cpf` ON cpf.entity_id = p.entity_id LEFT JOIN `catalog_category_product` AS `ccp` ON ccp.product_id = p.entity_id WHERE ( () ) AND (p.entity_id = '1696') LIMIT 1
Kindly let me know what is going wrong and how can I resolve this.
There is some inconsistency in database catalog_product_flat_1 table, Please empty all flat tables and try. Please take backup before empty the tables.

Advantage Database 8.1 SQL IN clause

Using Advantage Database Server 8.1 I am having trouble executing a successful query. I am trying to do the following
SELECT * FROM Persons
WHERE LastName IN ('Hansen','Pettersen')
To check for multiple values in a column. But I get an error when I try to execute this query in Advantage.
Edit - Error
poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [iAnywhere Solutions][Advantage SQL Engine]Expected lexical element not found: ( There was a problem parsing the
WHERE clause in your SELECT statement. -- Location of error in the SQL statement is: 46
And here is the SQL i'm executing
select * from "Pat Visit" where
DIAG1 IN = ('43644', '43645', '43770', '43771', '43772', '43773', '43774',
'43842', '43843', '43845', '43846', '43847', '43848', '97804', '98961',
'98962', '99078')
Done
Does anyone have any Idea how I could do something similar in advantage that would be efficient as well?
Thanks
You have an extraneous = in the statement after the IN. It should be:
select * from "Pat Visit" where
DIAG1 IN ('43644', '43645', <snip> )