I am getting error while executing the following query: Failed to resolve the arguments
query = '
SELECT distinct "Product Name"
FROM df_sales
WHERE "End Customer" = df_End_customer.iloc[0]
df_Product_name = pysqldf(query)
This shows no error but df_Product_name shows no data, when querying with a constant it displays data. Can someone please guide me.
query = """
SELECT distinct "Product Name"
FROM df_sales
where "End Customer" = "{0}" """.format(df_End_customer.iloc[0])
df_Product_name = pysqldf(query)
df_Product_name
Related
I have a below code which is giving error when I changed the sSQL parameter to join query. Earlier select command on v_d_investigation view was there. I changed the query to join v_d_investigation on v_d_memo views. Error i am getting "One or more error occurred during processing of command. From keyword not found where expected". Please suggest on this...
sSQL += "order by opened_dt Desc "
fDataSet = gConn.getDataSet(sSQL, "v_d_investigation")
'fDataSet = gConn.getDataSet(sSQL)
totalRecords = Me.lvList.AddItems(fDataSet, "v_d_investigation")
I'm trying to execute the following sql (Netezza) query in R
df <- sqlQuery(con, 'SELECT "ID", "Job ID", "Job Status" FROM DB1.EUL."Job Order"
WHERE "Job ID" = 'JBNT00000888'', as.is=TRUE)
But it gives errors out:
ERROR: Could not SQLExecDirect
Is there any other way to pass the string through?
My query and VBA command that generate this error are extremely simple but I am missing something.
I have a button in a form that creates a report. The reports has the following query as a record source:
SELECT Bewerber.*, Recruiter.*, sys_var.*
FROM (Recruiter INNER JOIN Bewerber ON Recruiter.ID = Bewerber.Recruiter)
INNER JOIN sys_var ON Recruiter.Key &"_FRAGEN" = sys_var.Key;
All of these tables have an ID.
This is the code for the Button.Click event:
DoCmd.OpenReport "rptRecruitingvorlage", acViewPreview, , "Bewerber.ID = " & ID
What am I missing??
Thank you for all your help.
When executing the below code I get the following error.
"Additional information: Conversion from string "_01202478334" to type 'Double' is not valid."
Code:
Using connn As New SqlClient.SqlConnection("server=inlt01\SQLEXPRESS; database=DaisyServices; integrated security=yes")
Using cmdz As SqlClient.SqlCommand = conn.CreateCommand()
cmdz.CommandText = "SELECT CLI, FromDate, ToDate, [Description], TotalCost, COUNT(*) as Count FROM [" + FileNameOnly + "] GROUP BY CLI, FromDate, ToDate, [Description], TotalCost HAVING COUNT(*) > 1"
connn.Open()
If cmdz.ExecuteScalar() > 1 Then
'Error if name in use
MessageBox.Show("Duplicate records exist on imported file!!")
In order to troubleshoot I removed the CLI field, but then I get a new error
"Additional information: Operator '>' is not defined for type 'Date' and type 'Integer'"
I am using some very similar code on a separate form and it runs without any error.
Here is my working code:
Using connn As New SqlClient.SqlConnection("server=inlt01\SQLEXPRESS; database=DaisyBilling; integrated security=yes")
Using cmdz As SqlClient.SqlCommand = conn.CreateCommand()
cmdz.CommandText = "SELECT CustomerCLI, calldate, calltime, duration, TelephoneNumber, COUNT(*) as Count FROM [" + FileNameOnly + "] GROUP BY CustomerCLI, calldate, calltime, duration, TelephoneNumber HAVING COUNT(*) > 1"
connn.Open()
If cmdz.ExecuteScalar() > 1 Then
'Error if name in use
MessageBox.Show("Duplicate records exist on imported file!!")
How come the code works on my other form, but not on this one?
NB. The SQL executes ok if I run the query direct from SQL server
Any help greatly appreciated
ExecuteScalar is intended more for when the query returns one value only. If you put the count as the first element in your SELECT, it will work.
From the documentation for SqlCommand.ExecuteScalar Method:
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
I am trying to use SQL to return all entries from a user's friends.
The logic is that the session id is set as user id, which corresponds to a user's ID in the user table.
This should then link to either linkID1 or linkID2 in the friendslink table
$sql =
"SELECT *
FROM ubuser
INNER JOIN ubFriendsLink
ON ubuser.usr_ID=ubFriendsLink.ub_lnkID1
OR ubuser.usr_ID=ubFriendsLink.ub_lnkID2
WHERE ubFriendsLink.ub_lnkID1= ".$_SESSION['usr_ID'] ."
OR ubFriendsLink.ub_lnkID2= ".$_SESSION['usr_ID'] ."
GROUP BY ubuser.usr_ID;";
Edit: I have changed the statement so it no longer contains *, however i am now getting the following error:
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft JET Database Engine Description: You tried to execute a query that does not include the specified expression 'usr_firstname' as part of an aggregate function.'
The ammended sql looks like this:
$sql =
"SELECT ubuser.usr_ID, ubuser.usr_firstname, ubuser.usr_lastname,
ubuser.usr_DOB,ubuser.usr_email
FROM ubuser
INNER JOIN ubFriendsLink
ON ubuser.usr_ID=ubFriendsLink.ub_lnkID1
OR ubuser.usr_ID=ubFriendsLink.ub_lnkID2
WHERE ubFriendsLink.ub_lnkID1= ".$_SESSION['usr_ID'] ."
OR ubFriendsLink.ub_lnkID2= ".$_SESSION['usr_ID'] ."
GROUP BY ubuser.usr_ID;";
However, the above code generates an error in from clause. Any ideas please?
You can't select all columns while grouping data.
SELECT ubuser.usr_ID