When I am trying to run below code in google colab:
#Get required Data
data8 = pd.read_sql_query('''SELECT Person.Name, Person.Gender
FROM M_Cast left JOIN Person USING (PID)
WHERE PID NOT IN
(
SELECT DISTINCT(PID) as PID
FROM
(
SELECT *, LEAD(M_year, 1, 0) OVER (PARTITION BY Actor ORDER BY M_year ASC) AS N_Year
FROM
(
SELECT trim(person.PID) as PID, trim(Person.Name) as Actor, substr(Movie.year,length(Movie.year)-3,4) as M_Year
FROM Person
LEFT JOIN M_Cast USING (PID)
LEFT JOIN Movie USING (MID)
)
)
WHERE (N_Year-M_Year)>3
)''',con)
print('Output 8: Following is the list of actors never unemployed more than 3 years.(Included actors having single movie):\n')
data8
Colab throws me an error
DatabaseError: Execution failed on sql
: near "(": syntax error
while its running well on my jupyter notebook
Default sqlite version in Colab is 3.22, but window function is supported in 3.25+. So you need to upgrade it first
!add-apt-repository -y ppa:sergey-dryabzhinsky/packages
!apt update
!apt install sqlite3
Then restart runtime because sqlite is already loaded before.
MENU > Runtime > Restart runtime
Then check that it's a new version
import sqlite3
print(sqlite3.sqlite_version) # 3.33.0
Related
I get ERROR: relation "case_avg" does not exist in my sql request
with case_avg AS
(select
avg(vv.total_vcpu) as avgvcpu,
avg(vv.total_vram) as avgvram,
avg(vv.total_hdd) as avghdd,
pod,
report_date
from common.vmware_vm vv
group by pod,report_date)
select
(ca.avgvcpu-v.total_vcpu) as vcpu,
(ca.avgvram-v.total_vram) as vram,
(ca.avghdd-v.total_hdd) as hdd,
Concat(lower(v.vdc),lower(v.org)) as org_vdc
from
common.vmware_vm v
inner join case_avg ca on
ca.pod = v.pod and ca.report_date = v.report_date
group by org_vdc
How i can resolve this?
I installed Solr from CDH which version is 4.10.3-cdh5.13.0.
My job like one sql work like,How to realize by Solr4:
select D,E,sum(A),sum(B) from DOC where C='balabala' group by D , E;
I try this one,but only one column in group section.
&stats=on
&stats.field=A
&stats.field=B
&stats.facet=D
In Solr5,code below works,but in Solr4 failed:
facet=true&stats=true&stats.field={!tag=piv1}A&facet.pivot={!stats=piv1}D,E
Is there one approach ?
and one more question:
how to realize
select D,E,sum(A*B) from DOC where C='balabala' group by D , E;
I have a table with data and I need to make a join by two fields.
I wrote a request, but it does not work
SELECT *
FROM Data t1
JOIN Data t2 ON t1.s = t2.o
the code is
val csvTableSource = CsvTableSource
.builder
.path("src/main/resources/data.dat")
.field("s", Types.STRING)
.field("p", Types.STRING)
.field("o", Types.STRING)
.field("TIMESTAMP", Types.STRING)
.fieldDelimiter(",")
.ignoreFirstLine
.ignoreParseErrors
.commentPrefix("%")
.build()
tableEnv.registerTableSource("Data", csvTableSource)
val query = "SELECT * FROM Data t1 JOIN Data t2 ON t1.s = t2.o"
val table = tableEnv.sqlQuery(query)
I get the following exception
Exception in thread "main" org.apache.flink.table.api.TableException: Cannot generate a valid execution plan for the given query:
FlinkLogicalJoin(condition=[=($0, $6)], joinType=[inner])
FlinkLogicalTableSourceScan(table=[[Data]], fields=[s, p, o, TIMESTAMP], source=[CsvTableSource(read fields: s, p, o, TIMESTAMP)])
FlinkLogicalTableSourceScan(table=[[Data]], fields=[s, p, o, TIMESTAMP], source=[CsvTableSource(read fields: s, p, o, TIMESTAMP)])
This exception indicates that the query uses an unsupported SQL feature.
Please check the documentation for the set of currently supported SQL features.
I guess, you are trying to run this query in a streaming environment.
Non-windowed joins on streaming tables were added with Flink 1.5.0.
So you are trying to use a feature that is not supported in Flink 1.4.2 yet.
You can either switch to a batch environment which should be possible given that you are reading CSV files or upgrade to Flink 1.5.0.
First, i show my tables and my query:
Tbl_type: id, description (1,Type A)-(2,Type B)-(3,Type C)
Tbl_operation: id, client, type, import (1,1,1,100.00)-(2,1,1,75.00)-(3,1,1,44.00)-(4,1,2,90.00)-(5,1,2,11.00)
When i exe this query :
SELECT Operation.Client, Type.description AS Type, Count(Operation.Id) AS Nr
FROM Tipo LEFT JOIN
Operation
ON Type.Id = Operation.type
GROUP BY Type.description, Operation.Client;
i got like output:
Client,Type,Nr (1,Type A,3)-(1,Type B,2)
but, i want to obtained this:
Client,Type,Nr (1,Type A ,3)-(1,Type B,2)-(1,Type C,0)
Also, I'd had a second client (id=2)
Tbl_operation: id, client, type, import (1,1,1,100.00)-(2,1,1,75.00)-(3,1,1,44.00)-(4,1,2,90.00)-(5,1,2,11.00)-(6,2,3,66.00)
Then, the consult should do this too:
Client,Type,Nr (1,Type A,3)-(1,Type B,2)-(1,Type C,0)-(2,Type A,0)-(2,Type B,0)-
(2,Type C,1)
This is possible? or i have to do a subselect?. I have tried to use full outer join but it doesnt work because it shows only registered rows.
Hello I updated my Joomla from 2.5 to 3.5 and VM2 to VM3. Everything so far is working but in some products of VirtueMart I get this error vmError: Couldnt create thumb, file not found after update and when I click on the product I get this one:
YOU HAVE AN ERROR IN YOUR SQL SYNTAX; CHECK THE MANUAL THAT CORRESPONDS TO YOUR MARIADB SERVER VERSION FOR THE RIGHT SYNTAX TO USE NEAR 'NATURA"" ORDER BY PRODUCT_NAME DESC, VIRTUEMART_PRODUCT_ID DESC LIMIT 1' AT LINE 1 SQL=SELECT P.VIRTUEMART_PRODUCT_ID, L.PRODUCT_NAME,L.PRODUCT_NAME FROM #__VIRTUEMART_PRODUCTS AS P INNER JOIN #__VIRTUEMART_PRODUCTS_EL_GR AS L USING (VIRTUEMART_PRODUCT_ID) LEFT JOIN #__VIRTUEMART_PRODUCT_SHOPPERGROUPS AS PS ON P.VIRTUEMART_PRODUCT_ID = PS.VIRTUEMART_PRODUCT_ID LEFT JOIN #__VIRTUEMART_PRODUCT_CATEGORIES AS PC ON P.VIRTUEMART_PRODUCT_ID = PC.VIRTUEMART_PRODUCT_ID WHERE ( PC.VIRTUEMART_CATEGORY_ID = 1 AND ( PS.VIRTUEMART_SHOPPERGROUP_ID= "1" OR PS.VIRTUEMART_SHOPPERGROUP_ID IS NULL ) AND P.PUBLISHED="1" ) AND P.VIRTUEMART_PRODUCT_ID!="78" AND L.PRODUCT_NAME <= "ΠΟΔΟΜΑΚΤΡΑ ΒΕΛΟΥΤΕ "NATURA"" ORDER BY PRODUCT_NAME DESC, VIRTUEMART_PRODUCT_ID DESC LIMIT 1
What can i do to fix this?
it was the ", i rename the product and now i don't get error on sql.