SQL Join operation error [closed] - sql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to write an SQL code in MS Access 2010 as follows:-
select WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
right join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
where (WOWPerformanceData_tbl.Style=[Enter Style nr:]);
Upon running the code, Access returns an error in the join operation pointing to the fourth line and selects PrintPromotions
Any feedback will be appreciated..
Thank you.

Should that be PrintPromotions and not PrintPromtions ?

This is fine as the where clause is an evaluation on the entire set.
SELECT WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
LEFT join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
where (WOWPerformanceData_tbl.Style=[Enter Style nr:]);
This would exclude records from printPromotions that were not in wowPerformanceData_tbl, which negates the right join.:
SELECT WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
right join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
where (WOWPerformanceData_tbl.Style=[Enter Style nr:]);
This is how you would do it to keep all records from PrintPromotions and those that matched in wowperofrmanceData_tbl.
SELECT WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
right join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
AND (WOWPerformanceData_tbl.Style=[Enter Style nr:]);

Related

How to do join using select [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 days ago.
This post was edited and submitted for review 2 days ago.
Improve this question
SQL Newbie here ...
Service_plan table has a record per customer with PKEY service_plan_id
SERVICE_PLAN_ID table keeps track of version changes with same PKEY
When I run this query [other selects omitted for brevity] in Oracle 10.2.0 iSQL command line, I get an error:
select S1.service_plan_id as TN,V1.VERSION_ID as Version
from Service_plan S1
inner join
(select distinct service_plan_id, max(VERSION_ID)
from SERVICE_PLAN_VERSION
where service_ID='COLL'
group by service_plan_id) as V1
on V1.SERVICE_PLAN_ID = S1.SERVICE_PLAN_ID
where S1.SERVICE_ID='COLL';
Error: missing key word on the "group by service_plan_id) as V1" line - it points to the "as" as the problem.
Any thoughts? Thx
Tried the standalone select and it works fine

Access SQL Syntax error - Unable to find the error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 days ago.
Improve this question
SELECT AgentData.AgentLoginID,AgentData.KPIName,Minimum.Indicator,Minimum.PMonth,Minimum.PYear,Minimum.Min,
IIf(InStr([AgentData].[Goal],'%')>0,(Left([AgentData].[Goal],Len([AgentData].[Goal])-1)/100),[AgentData].[Goal]) AS Goal,
AgentData.Weightage,
Round(IIf(InStr([AgentData].GoalValue,'%')>0,(Left([AgentData].GoalValue,Len([AgentData].GoalValue)-1)/100),[AgentData].GoalValue),2) AS GoalValue,
Round(IIf([Minimum].[Indicator]='P',(IIf([Goal]=0,Null,[GoalValue]/[Goal]),IIf(([Minimum].[Indicator]='N' And ([Minimum].[Min]=0 Or [Minimum].[Min]=(format(0,"Percent")),Null,([Minimum].[Min]-[GoalValue]/[Minimum].[Min]),4) AS [Value],
Round([AgentData].Weightage*Value,4) AS Product FROM Minimum INNER JOIN AgentData ON Minimum.KPIName = AgentData.KPIName;
I have been trying to execute this code in access, but no success, i keep getting a syntax error, missing operator in expression, but unable to figure out what the issue is, so wondering if anyone could help, i get an error with the SQL statement marked in bold
SELECT AgentData.AgentLoginID, AgentData.KPIName, Minimum.Indicator, Minimum.PMonth, Minimum.PYear, Minimum.Min,
IIf(InStr([AgentData].[Goal],'%')>0,(Left([AgentData].[Goal],Len([AgentData].[Goal])-1)/100),[AgentData].[Goal]) AS Goal,
AgentData.Weightage,
Round(IIf(InStr([AgentData].GoalValue,'%')>0,(Left([AgentData].GoalValue,Len([AgentData].GoalValue)-1)/100),[AgentData].GoalValue),2) AS GoalValue, Round(IIf([Minimum].[Indicator]='P',IIf([Goal]=0,Null,[GoalValue]/[Goal]),
IIf(([Minimum].[Indicator]='N' And [Minimum].[Min]=0),Null,([Minimum].[Min]-[GoalValue])/[Minimum].[Min])),4) AS [Value],
Round([AgentData].Weightage*Value,4) AS Product
FROM Minimum INNER JOIN AgentData ON Minimum.KPIName = AgentData.KPIName;
The above query runs perfectly fine, but i get a snytax errors when i add the OR operator for Minimum.Min as i want it to exectue in two scenarios , one is when Minmum.min is 0 or when minimum.min = 0%

ORA-00923 from keyword not found when trying to do a join [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
When I previously ran this code for a join:
SELECT
Outlet.Address, Outlet.ManagerNumber,
Department.DepartmentName, Department.FloorArea
FROM
Outlet
INNER JOIN
Department ON Outlet.OutletNumber = Department.OutletNumber;
It worked. However, I am trying to run a similar join it simply does not work:
SELECT
Product.Description Product.Price,
ProductAtOutlet.Quantity,
ProductAtOutlet.OutletNumber
FROM
Product
INNER JOIN
ProductAtOutlet ON Product.ProductNumber = ProductAtOutlet.ProductNumber;
And I keep getting the error message
ORA-00923 from keyword not found
missing comma, after description?
SELECT
Product.Description,
Product.Price,
ProductAtOutlet.Quantity,
ProductAtOutlet.OutletNumber
FROM
Product
INNER JOIN ProductAtOutlet ON Product.ProductNumber = ProductAtOutlet.ProductNumber;
The problem is that you are missing a comma after Product.Description. This causes the parser to see Product.Price as a column alias. Having a . in an unquoted alias results in a parser error.

Postgresql missing FROM-entry for table [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have 2 tables
messages
respondents
and I'm trying to join them using a simple inner join query
SELECT
Message.content,
Message.created_at,
Respondent.name
FROM
MESSAGES
INNER JOIN RESPONDENTS ON Message.respondent_id = Respondent.id;
and I'm getting this error:
ERROR: missing FROM-clause entry for table "message"
LINE 1: ...dent.name FROM MESSAGES INNER JOIN RESPONDENTS ON Message.re...
Can anyone help me out??
There are two typos in your query. Try this - assuming your tables are called respondents and messages:
SELECT
messages.content, messages.created_at, respondents.name
FROM messages
INNER JOIN respondents ON messages.respondent_id = respondents.id;

Record Count Different in VBA Versus Access [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have an Excel VBA workbook that generates a SQL statement in the form of a string. I pass this SQL into a recordset object and use the CopyFromRecordSet function to dump out the data into an Excel worksheet.
The above method gives me 67 records. If I take the exact SQL generated in VBA and paste into a new query within Access it provides 400 records.
SQL is the following:
SELECT tbJob.jobID,
tbTasks.tskName,
tbTaskCat.catName,
tbTasks.tskActivity,
tbJob.JobDueDate,
tbJob.jobCompletedDate,
tbJob.jobCreatedOn,
tbJobStatus.statusDes,
tbStaff.staffForename & ' ' & tbStaff.staffSurname AS Assignee
FROM tbJobStatus
INNER JOIN (tbStaff
INNER JOIN (tbTaskCat
INNER JOIN (tbTasks
INNER JOIN tbJob
ON tbTasks.tskID = tbJob.jobTaskID)
ON tbTaskCat.catID = tbTasks.tskCatID)
ON tbStaff.staffID = tbJob.jobAssignedToID)
ON tbJobStatus.statusID = tbJob.jobStatusID
WHERE tbJob.jobStatusID = 4
AND tbJobStatus.statusDes <> 'Deleted'
ORDER BY tbJob.jobID;
I am struggling to explain why the difference occurs.
Any help would be appreciated. I have searched around the web but couldn't find a solution, if you know of one please post the link.
Thanks in advance.
Stuart