Every time I try to run this select statement I get told there is a syntax error. Can someone please help me figure out what the syntax error is?
SELECT
ZERO_SALES.STORE_NUMBER,
COUNT( * ) AS COLUMN0001,
ZERO_SALES.SKU_NUMBER
FROM
MM4R5LIB.ZERO_SALES ZERO_SALES,
MM4R5LIB.INVMST INVMST,
MM4R5LIB.OPORBK OPORBK,
MM4R5LIB.TBLSTT TBLSTT,
MM4R5LIB.TBLSTR TBLSTR
WHERE
ZERO_SALES.SKU_NUMBER = INVMST.INUMBR
AND INVMST.INUMBR = OPORBK.INUMBR
AND ZERO_SALES.STORE_NUMBER = OPORBK.ISTORE
AND OPORBK.ISTORE = TBLSTT.STRNUM
AND TBLSTT.STRNUM = TBLSTR.STRNUM
AND ZERO_SALES.STORE_NUMBER = 6009
AND ZERO_SALES.SKU_NUMBER =(233879, 659250, 240896)
GROUP BY
ZERO_SALES.STORE_NUMBER,
ZERO_SALES.SKU_NUMBER
I am trying to get a list of the number of occurrences for each SKU number for this particular store.
Related
I am trying to update some fields in oracle nested table, so I can insert some values, the problem is I am unable to retrieve the results as nested table. The following is the query I am trying to run:
update utilisation_obj
set listerefaccess = (
select ref(a)
from refaccessoireimb a
where a.refaccessoire.accessoire in ('ballon', 'barre')
)
where deref(utilisation_obj.REFTITREDENUM).titreDeNumero = 'Les Zoupalas' and
deref(utilisation_obj.REFUTILISATEUR).nom = 'Louis';
The error is the following:
inconsistent datatypes: expected CIRQUEOR.LISTEREFACCESS_T got : REF CIRQUEOR.REFACCESSOIRE_T
I found this solution but I was hoping for a more dynamic solution since this one would force me to know how many rows I expect to have
INSERT INTO Utilisation_Obj
Select Ref(N), Ref(P), ListeRefAccess_T(RefAccessoire_T(ref(A1)),RefAccessoire_T(ref(A2)))
From Numeros_Obj N, Personnel_Obj P, Accessoire_Obj A1,Accessoire_Obj A2
Where N.TitreDeNumero = 'Les Zoupalas' and P.Nom = 'Louis' and
A1.accessoire = 'ballon' and A2.accessoire = 'barre';
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 wish to update a table using, but need to use another table to get the correct field. The new information is not taken from another field from another table.
The following SQL statement returns the correct information:
SELECT PURCHASEHEADER.ORDERNOTES
FROM PURCHASEHEADER, ASSEMBLYLINESOURCE
WHERE ASSEMBLYLINESOURCE.HEADERSYSUNIQUEID = 72637001
AND PURCHASEHEADER.ORDERNUMBER = ASSEMBLYLINESOURCE.PURCHASEORDERNUMBER
I have tried the following:
UPDATE PURCHASEHEADER SET PURCHASEHEADER.ORDERNOTES = 'Updated'
WHERE EXISTS (
SELECT 1 FROM ASSEMBLYLINESOURCE
WHERE PURCHASEHEADER.ORDERNUMBER = ASSEMBLYLINESOURCE.PURCHASEORDERNUMBER
) AND ASSEMBLYLINESOURCE.HEADERSYSUNIQUEID = 72637001
An error is returned saying: " ...Column Unknown ASSEMBLYLINESOURCE.HEADERSYSUNIQUEID..." but it does exist as it works in the first query.
I have seen similar posts from Mark Rotteveel dated July 2017, but still can't get it to work.
There is an issue with your closing bracket. Try this, it worked for me.
UPDATE PURCHASEHEADER set PURCHASEHEADER.ORDERNOTES = 'Updated'
WHERE EXISTS (SELECT 1 FROM ASSEMBLYLINESOURCE WHERE
PURCHASEHEADER.ORDERNUMBER = ASSEMBLYLINESOURCE.PURCHASEORDERNUMBER AND
ASSEMBLYLINESOURCE.HEADERSYSUNIQUEID = 72637001)
I am having an issue with my SELECT query. I am trying to find items that do not start with "50700" and have an enabled flag of 1, are in category 4 and sub category 4. Below is the query i have but it is not returning any results when i know there are some. Please note TBL1.FIELD1 = ITM_ID, TBL1.FIELD2 = ENABLED, TBL2.FIELD1 = CAT_ID, TBL2.FIELD2 = SUBCAT_ID.
SELECT DB_NAME.dbo.TBL1.FIELD1
, DB_NAME.dbo.TBL1.FIELD2
, DB_NAME.dbo.TBL2.FIELD1
, DB_NAME.dbo.TBL2.FIELD2
FROM DB_NAME.dbo.TBL1
, DB_NAME.dbo.TBL2
WHERE DB_NAME.dbo.TBL1.FIELD1 NOT LIKE '50700%'
AND DB_NAME.dbo.TBL1.FIELD2 = 1
AND DB_NAME.dbo.TBL2.FIELD1 = 4
AND DB_NAME.dbo.TBL2.FIELD2 = 4
You can break the query into different subqueries for debug purpose, this way you can figure out which "AND" condition is not working.
For Example:
Firstly I guess you should try a simple query on TBL1.FIELD1 with the simple query :
select TBL1.FIELD1 from DB_NAME.dbo.TBL1 where DB_NAME.dbo.TBL1.FIELD1 NOT LIKE '50700' ;(*if TBL1.FIELD1 is of String type, else go for TBL1.FIELD1 != 50700 * )
Then if you get results ,try to do "AND" with the TBL1.FIELD2 condition.
select TBL1.FIELD1
from DB_NAME.dbo.TBL1
where DB_NAME.dbo.TBL1.FIELD1 NOT LIKE '50700'
and DB_NAME.dbo.TBL1.FIELD2 =4 ;
This way you can proceed further and debug the query. Hope it helps :)
I am trying to self educate myself in SQL in order to better use databases at work. I am currently trying to code an SQL query in Oracle Application Express that will provide me with a report for management, however I am receiving the following error message:
ORA-01747: invalid user.table.column, table.column, or column specification
I have spent countless hours searching for the bug and doing research and I am getting nowhere, which is quite frustrating as I feel its probably something rather easy. My research has shown me that the probable cause of my error is that I have tried to reference a column name, but the column name used is a reserved word in Oracle. Unfortunately, I am having trouble pinpointing what exactly... Please see below for the code:
SELECT Channel.Channel_Number, Supplier.Supplier_Name, package.Package_Name, Program.Program_name, Rating.Rating_Code, Weekly_Guide.ShowTime
FROM Channel, Supplier, package, Program, Rating, weekly_guide, channel_package
Where weekly_guide.date = ''
AND channel.channel_number = weekly_guide.channel_number
AND weekly_guide.Program_ID = Program.Program_ID
AND channel.channel_number = channel_package.channel_number
AND channel_package.package_ID = package.package_ID
AND Program.rating_code = rating.rating_code
AND Program_list.Program_ID = Program.Program_ID
AND Program_list.list_ID = list.list_id
AND list.supplier_ID = Supplier.supplier_ID
It's most likely date from your Where clause. You'll need to wrap the reserved word in quotes. The name will then be case sensitive, so make sure you have the correct case for date in your query
SELECT Channel.Channel_Number, Supplier.Supplier_Name, package.Package_Name, Program.Program_name, Rating.Rating_Code, Weekly_Guide.ShowTime
FROM Channel, Supplier, package, Program, Rating, weekly_guide, channel_package
Where weekly_guide."date" = ''
AND channel.channel_number = weekly_guide.channel_number
AND weekly_guide.Program_ID = Program.Program_ID
AND channel.channel_number = channel_package.channel_number
AND channel_package.package_ID = package.package_ID
AND Program.rating_code = rating.rating_code
AND Program_list.Program_ID = Program.Program_ID
AND Program_list.list_ID = list.list_id
AND list.supplier_ID = Supplier.supplier_ID