This question already has an answer here:
MS Access Query with CASE statement
(1 answer)
Closed 3 years ago.
Getting Syntax Error( missing operator) in query expression, What am I getting wrong?
SELECT
ExportUF_NEW.Position,
ExportUF_NEW.[User Defined Field 03]
(CASE
WHEN ExportUF_NEW.[User Defined Field 03] = OP THEN "Production"
WHEN ExportUF_NEW.[User Defined Field 03] = STM THEN "Thermal"
ELSE NULL
END) AS OperationGroup
FROM ExportUF_NEW
WHERE (((ExportUF_NEW.[User Defined Field 03]) Is Not Null))
Expect an outcome to new column "OperationGroup" based on ExportUF_NEW[User Defined Field 03].
MS Access did not support CASE WHEN, use switch instead.
Similar link: What is the equivalent of Select Case in Access SQL?
Related
This question already has an answer here:
Replacement for Left command in SQLite SQL
(1 answer)
Closed 7 months ago.
How to remove all characters from / to &.
UPDATE bal SET Perevod=substr(Perevod, INSTR(Perevod, '/.+&')-1)
WHERE INSTR(Perevod, '/.+&')>0;
You can use this because I believe there is no LEFT function in SQLite:
UPDATE bal
SET Perevod = substr(Perevod, 1, INSTR(Perevod, '/')-1)
WHERE INSTR(Perevod, '/')>0;
DEMO
This question already has answers here:
getting "invalid column" when trying to use column alias in a query
(3 answers)
Closed 1 year ago.
SELECT .....
'NewReserveSum' =
case
when h.ApprovedCurrencyID = 417 then new.ReserveSumV
else [dbo].[GetCurrencyRate](h.ApprovedCurrencyID, #PresentDate) * new.ReserveSumV
end,
(o.ReserveSummN - NewReserveSum) as 'DifferenceReserveSummN'
FROM ......
I want to use the ** NewReserveSum ** variable in the following columns, but I got an error:
Invalid column name 'NewReserveSum'
How can I do it correctly in MSSQL?
In SQL, = is comparison, not assignment
In a SELECT statement, you can use AS to give a name top an expression column:
SELECT
case
when h.ApprovedCurrencyID = 417 then new.ReserveSumV
else [dbo].[GetCurrencyRate](h.ApprovedCurrencyID, #PresentDate) * new.ReserveSumV
end as NewReserveSum,
...
This question already has an answer here:
Getting error ORA-00909: invalid number of arguments
(1 answer)
Closed 1 year ago.
I'm trying to retrieve report from postgreSQL database to Oracle data base, but it isn't working as I thought. I tried to find related tables in Oracle database and found them as SOR tables, some data is in Datamarts.
SQL Error [909] [42000]: ORA-00909: invalid number of arguments
SQL statement that works just fine in postgreSQL:
`SELECT
'loan' as product,
count(cc.id),
cc."type",
cc.topic,
cc.direction,
TRIM(cc.subject) AS subject,
case when EXISTS (SELECT caf.communication_id
FROM serp_bigmoney_lv.comm_attachment_files caf where cc.id = caf.communication_id) then
'yes'
else 'no' end as file_attached,
concat(us."name",' ',us.surname) as user_name,
cc.createdat::date
from erp_bigmoney_lv.comm_communication cc
left join erp_bigmoney_lv.erp_users us on us.user_id = cc.created_by
where cc."type" = 'note'
GROUP BY cc.createdat::date, user_name, file_attached, cc.direction, cc.topic, cc."type",
product, cc.subject`
CONCAT function only accept two arguments use || to concatenate the fields like:
FIELD_1 || ‘ ‘ || FIELD_2
This question already has answers here:
SQL How to Select the most recent date item
(6 answers)
Closed 2 years ago.
I would like to select last inserted data in my table.
I tried :
Source = "SELECT * FROM HistoSpreadLiq WHERE DateSpread=MAX(DateSpread)"
But this doesn't work -> returns : Error Automation..
MAX(DateSpread) should return 04/11/2020
DateSpread is a date format in my AccessDB
And when I hard code:
Source = "SELECT * FROM HistoSpreadLiq WHERE DateSpread=04/11/2020"
It does work, what am I missing?
Please note that I execute this SQL request in Excel and my database is an Access database (.accdb)
Then answer was that I had to do an other select :
"SELECT * FROM HistoSpreadLiq WHERE DateSpread=(SELECT Max(DateSpread) FROM HistoSpreadLiq)"
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Error within Where statement in LINQ
I need to get a list of all quotes that have been changed since a certain DateTime ( for export reasons ).
The catch is of course that if a quote detail changes, the quote should also be exported even if the the quote itself hasn't changed.
I would solve this very easily in T-SQL as :
Select q.QuoteNumber from quote q inner join quotedetails qd on q.quoteid = qs.quoteid
where ((q.lastmodified > ?1) or (qd.lastmodified > ?1)) and (qd.SomeField = 'OK')
However, with Linq to CRM 2011, I stumble upon a restriction.
var quotelist = from q in xrm.quoteSet
join qd in xrm.quoteDetailSet
on q.QuoteId equals qd.QuoteId.Id
where (q.lastmodified > ?1 | qd.lastmodified > ?1) & qd.Somefield == "OK"
select q.QuoteNumber
It says that the Quote entity has no attribute SomeField.
Just FYI, this is just an example query to show the problem. I cannot switch Quote and QuoteDetail in my real life query.
What is the cleanest way to convert my T-SQL query (as is) to a Linq query for CRM 2011?
Have you looked at the MSDN samples? I'm confused why you are getting the error "no attribute" on the Quote entity when your prefix is referencing QouteDetail (qd.Somefield)
The only other thing that looks suspicious is your single & and | in the where clause. I believe you should have those doubled up: && and ||
Any chance you created your early bound objects with the SomeField attribute, and then someone removed the field?