Why do I get this error? I'm trying to do queries and for this i need of several selects from different tables, without any combination, but I'm getting this error and I don't known why.
Syntax error(s) [missing EOF at 'select']
Code:
select
d.tdok typ,
d.nr numer,
d.symbmg symbol,
d.data dataDok,
d.dokumwe dokumWe,
d.datawe datawe,
d.idkntrh idKth,
d.kwotadok kwotadok,
d.kwotavat,
k.nazwa1 nazwa1,
k.nazwa2 nazwa2
from dokum0 d
join kontrahent0 k on d.idkntrh=k.idkntrh
select t.kwota_n kwota_n
from dokumterm t
where t.dokum_id = id_dokum;
select p.id_pozdok0 AS settledCount
from pozdok p
where p.dokum_id = id_dokum;
select p.id_pozdok0 AS posCount
from pozdok p
where p.dokum_id=id_dokum;
select t.kupspr kupspr
from sltdok t
where t.tdok=tdok;
Can anyone help me?
You dont have semicolon (;) after end of first select... So this:
join kontrahent0 k on d.idkntrh=k.idkntrh
should be:
join kontrahent0 k on d.idkntrh=k.idkntrh;
Related
I'm trying to run the following query but keep getting the same error
Syntax error: Expected end of input but got identifier "BD_Dictionary"
at [3:1]
My query is:
SELECT
MI.* except(period_date, entity_level, email_access, period_filter)
BD_Dictionary.BD_EMAIL, BD_Dictionary.AREA_LEAD, BD_Dictionary.BD_LEADER
FROM
`mi-trial-365509.Trial.MI` as MI
INNER JOIN
`mi-trial-365509.Trial.BD Dictionary` as BD_Dictionary
ON
A.bd_email = BD_Dictionary.BD_EMAIL
LIMIT
1000
Sorry my bad, i forgot to put a comma in between the table source in SELECT command.
my code is now like this:
SELECT
MI.* except(period_date, entity_level, email_access, period_filter),
BD_Dictionary.BD_EMAIL, BD_Dictionary.AREA_LEAD, BD_Dictionary.BD_LEADER
FROM
`mi-trial-365509.Trial.MI` as MI
INNER JOIN
`mi-trial-365509.Trial.BD Dictionary` as BD_Dictionary
ON
MI.bd_email = BD_Dictionary.BD_EMAIL
LIMIT
1000
SELECT p.pnum, p.pname
FROM professor p, class c
WHERE p.pnum = c.pnum AND c.cnum = CS245 AND (SELECT COUNT(*) FROM (SELECT MAX(m.grade), MAX(m.grade) - MIN(m.grade) AS diff
FROM mark m WHERE m.cnum = c.cnum AND m.term = c.term AND m.section = c.section AND diff <= 20)) = 3
Incorrect syntax near ')'. Expecting AS, FOR_PATH, ID, or QUOTED_ID.
Consider the following example:
SELECT COUNT(1)
FROM SYSCAT.TABLES T
WHERE
(
-- SELECT COUNT(1)
-- FROM
-- (
SELECT COUNT(1)
FROM SYSCAT.COLUMNS C
WHERE C.TABSCHEMA=T.TABSCHEMA AND C.TABNAME=T.TABNAME
-- )
) > 50;
The query above works as is. But the problem is, that if you uncomment the commented out lines, you get the following error message: "T.TABNAME" is an undefined name. and least in Db2 for Linux, Unix and Windows.
You can't push external to the sub-select column references too deeply.
So, your query is incorrect.
It's hard to correct it, until you provide the task description with data sample and the result expected.
I can see a potential syntax errors: It seems that CS245 refers to a value c.cnum may take and not a column name. If that is the case, it should be enclosed in single quotes.
I´ve been trying to find the error in this statement for a few hours and can´t seem to find it.
It must have something to do with the AND connecting the two WHERE´s since when deleting the first WHERE it works:
SELECT E_AUFMASS_KOMMENTARE.FIBU_FIRMA,
E_AUFMASS_KOMMENTARE.AUFTR_NR,
E_AUFMASS_KOMMENTARE.KOMMENTAR,
AUFTR_EXT.ART_GRUPPE
FROM HHNG_AU.E_AUFMASS_KOMMENTARE
INNER JOIN HHNG_AU.AUFTR_EXT ON E_AUFMASS_KOMMENTARE.AUFTR_NR = AUFTR_EXT.AUFTR_NR
WHERE (E_AUFMASS_KOMMENTARE.AUFTR_NR = '1248823' )
AND WHERE NOT EXISTS( SELECT * FROM HHNG_AU.EX_KOMMENTARE WHERE EX_KOMMENTARE.AUFTR_NR = '1248823' )
Too many WHERE. You only need where once, then use ANDs and ORs to combine conditions:
SELECT E_AUFMASS_KOMMENTARE.FIBU_FIRMA, E_AUFMASS_KOMMENTARE.AUFTR_NR, E_AUFMASS_KOMMENTARE.KOMMENTAR, AUFTR_EXT.ART_GRUPPE FROM HHNG_AU.E_AUFMASS_KOMMENTARE INNER JOIN HHNG_AU.AUFTR_EXT ON E_AUFMASS_KOMMENTARE.AUFTR_NR = AUFTR_EXT.AUFTR_NR WHERE (E_AUFMASS_KOMMENTARE.AUFTR_NR = '1248823' ) AND NOT EXISTS( SELECT * FROM HHNG_AU.EX_KOMMENTARE WHERE EX_KOMMENTARE.AUFTR_NR = '1248823' )
I'm trying to execute the following query in Oracle:
SELECT c.id_cliente, c.nombre_cliente, c.apellidos_cliente
FROM cliente c
WHERE not exists (SELECT f.id_finca
FROM finca f
WHERE f.habitaciones = 3
EXCEPT
SELECT v.id_fincas
FROM visitas v
WHERE v.id_cliente = c.id_cliente)
But I am getting the error "missing right parenthesis".
The parenthesis are well-balanced, how can I solve this error?
Use MINUS instead of EXCEPT.
SELECT c.id_cliente,
c.nombre_cliente,
c.apellidos_cliente
FROM cliente c
WHERE NOT EXISTS (SELECT f.id_finca
FROM finca f
WHERE f.habitaciones = 3
MINUS
SELECT v.id_fincas
FROM visitas v
WHERE v.id_cliente = c.id_cliente)
there is no operator EXCEPT in Oracle. Use MINUS instead of it.
Additionally, your query seems weird: better try to make it with two not exists, I think it can give some performance.
I'm having some issues with a simple replace function. I need to replace a , with | for the point_of_contact column but I'm not sure why I'm receiving a -104 error. I have researched what I believed to be the correct syntax and tried a case statement and replace function but it is not working for me. I'm using DB2 and would appreciate your help.
SELECT RowNumber() over (PARTITION BY F13.DIM_PROJECT_ID ORDER BY F13.PROJECT_NAME),
F13.DIM_PROJECT_ID,
F2P.NAME_LAST,
F2P.NAME_FIRST,
--F2P.POINT_OF_CONTACT,
--CASE WHEN F2P.POINT_OF_CONTACT like '%,%' THEN Replace(F2P.POINT_OF_CONTACT,',','|') ELSE F2P.POINT_OF_CONTACT,
REPLACE(F2P.POINT_OF_CONTACT, ',', '|') AS F2P.POINT_OF_CONTACT,
F13.PROJECT_NAME,
F13.TITLE,
F2H.CREATION_DATE,
F13.FIELD A,
F2H.AMOUNT,
F2H.BUILDING_NAME,
F2H.PERCENTAGE,
F2H.ABILITY,
F2SB.HOURS16,
F2SB.HOURS33,
F2SB.HOURS100
FROM FACT_TABLE AS F13
INNER JOIN PERSONNEL AS F2P ON F13.DIM_PROJECT_ID = F2P.DIM_PROJECT_ID
LEFT JOIN JOB AS F2SB ON F13.DIM_PROJECT_ID = F2SB.DIM_PROJECT_ID
LEFT JOIN HOURS AS F2H ON F13.DIM_PROJECT_ID = F2H.DIM_PROJECT_ID
On your column alias, remove the table alias F2P.
REPLACE(F2P.POINT_OF_CONTACT, ',', '|') AS POINT_OF_CONTACT,