[Solved] Seeking assistance to configure SQL query

Creating tables and queries
Post Reply
cjrc
Posts: 2
Joined: Wed Jan 10, 2024 9:08 pm

[Solved] Seeking assistance to configure SQL query

Post by cjrc »

Hello,
I have a working MS SQL query that extracts data from an MS SQL database into MS Excel and wish to migrate it to OpenOffice Calc.

I have placed double quotation marks around all field names but am getting annoying syntax error message that is useless to diagnose the problem. The query extracts data from multiple Wonderlister tables.

Any assistance that would indicate what is necessary in order to get (Libre)OpenOffice to accept it is appreciated.
Thanks.


Error: SQL Status: HY000
Error code: 1000

Syntax error in SQL statement

Query as follows:

Code: Select all

select distinct 
	a."eBayUserID",
	a."ListingID",
	i."ConsignorName",
	j."SKU",
	a."eBayItemID",
	a."Title",
	a."DaysActive",
	a."StartTime",
        a."EndTime",
        a."CurrentPrice",
        a."QuantityAvailable",
        a."CurrentPrice"*a."QuantityAvailable" as "ExtendedValue",
        c."CategoryName" as "EbayCategoryParent",
	b."CategoryName" as "EbayCategory",
	f."Name" as "StoreCategory1_Parent",
	d."Name" as "StoreCategory1",
	e."Name" as "StoreCategory2",
	max(h."DateUploaded") as "max_DateUploaded",
	max(h."CreationDate") as "max_CreationDate",
	max(h."PictureLastModifiedOn") as "max_PictureLastModifiedOn"

FROM "WonderLister"."dbo"."Listing" a
LEFT JOIN "Wonderlister"."dbo"."eBayCategories" b
     ON a."PrimaryCategoryID" = b."CategoryID"

LEFT JOIN "Wonderlister"."dbo"."eBayCategories" c
     ON b."CategoryParentID" = c."CategoryID"

LEFT JOIN "Wonderlister"."dbo"."StoreCategories" d
     ON a."eBayUserID" = d."eBayUserID" and
	a."Storefront_StoreCategoryID" = d."CategoryID"

LEFT JOIN "Wonderlister"."dbo"."StoreCategories" e
     ON a."eBayUserID" = e."eBayUserID" and
	a."Storefront_StoreCategory2ID" = e."CategoryID"

LEFT JOIN "Wonderlister"."dbo"."StoreCategories" f
     ON a."eBayUserID" = e."eBayUserID" and
	d."ParentCategoryID" = f."CategoryID"

LEFT JOIN "wonderlister"."dbo"."ProductPictures" g  
     ON a."productId" = g."productid"

LEFT JOIN "wonderlister"."dbo"."Pictures" h
     ON g."pictureid" = h."pictureid"

LEFT JOIN "WonderLister"."dbo"."Consignors" i
     ON i."ConsignorID" = a."ConsignorID"

LEFT JOIN "WonderLister"."dbo"."Products" j
     ON j."ProductID" = a."ProductID"

WHERE a."ListingStatus" = 'Active' and 
      a."DaysActive" >= 0 and 
      b."SiteID" = 'US' and
       c."SiteID" = 'US'
      
group by 
	a."eBayUserID",
	a."ListingID",
	i."ConsignorName",
	j."SKU",
	a."eBayItemID",
	a."Title",
	a."CurrentPrice",
	a."QuantityAvailable",
	a."DaysActive",
	a."Starttime",
	a."EndTime",
	c."CategoryName",
	b."CategoryName",
	f."name",
	d."name",
	e."name"
order by "DaysActive"
Last edited by robleyd on Thu Jan 11, 2024 11:57 pm, edited 1 time in total.
Reason: Tagged [Solved]. Add green tick
OpenOffice 4.1.15 Windows 11
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Seeking assistance to configure SQL query

Post by Villeroy »

Put dbl-quotes around the aliase names "a", "i", "j" etc.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
cjrc
Posts: 2
Joined: Wed Jan 10, 2024 9:08 pm

Re: Seeking assistance to configure SQL query

Post by cjrc »

double quotes around alias names and strict application of column name upper/lower case worked successfully. Thank you Villeroy for the advice.
OpenOffice 4.1.15 Windows 11
Post Reply