How can I insert the file data into the table mysql? code: import pymysql.cursors import pymysql as MySQLdb import pymysql from Bio import SeqIO try: conexao = MySQLdb.connect(host=”…
Tag: sql
Daily forecast on a PySpark dataframe
I have the following dataframe in PySpark: DT_BORD_REF: Date column for the month REF_DATE: A date reference for current day separating past and future PROD_ID: Product ID COMPANY_CODE: Company ID CUSTOMER_CODE: Customer ID MTD_WD: Month to Date count of working days (Date = DT_BORD_REF) QUANTITY: Number of i…
Bigquery split rows by timestamp of event
In Google BigQuery, I have a list of events in a single support session which are tagged by event names. Each support issue resolved_time is the timestamp of the resolved event. Each issue start_time is the first occurrence of either of the events message, pending, or unresolved either at the absolute beginni…
SQLITE: Return 5 most recent records today and format date/time
I have a Xamarin.Forms app which has a ListView. I would like to populate the ListView with the 5 most recent items where the date is today’s date. If there are less than 5 items, the ListView should only display a row for each item (for example, if there is only one item, the ListView should only have …
Get max dates for each customer
Let’s say I have a customer table like so: I want to get 1 row per customer id that has the max(start_date) and if it’s the same date will use the max(created_at). Result should look like this: I’m having a hard time with window functions as I thought a partition by id would work but I have …
Oracle SQL: Get the previous values
I have two columns table: Id, and value. ID Value 1 2 AA 3 4 BB 5 6 7 8 CC 9 I need a query in Oracle to return the result as ID Value 1 2 AA 3 AA 4 BB 5 BB 6 BB 7 BB 8 CC 9 CC Is there anyway to do this? Thanks in
Concatenate or merge many columns values with a separator between and ignoring nulls – SQL Server 2016 or older
I want to simulate the CONCAT_WS SQL Server 2017+ function with SQL Server 2016 version or older in order to concatenate many columns which values are strings like that: Input: Output: Notice that the output result is a new column that concatenate all values separated by ‘|’. The default value sho…
Returning data from XML data in a column in a SQL Server database
Trying to extract data from a column in a SQL Server table. The column however is not of type XML but the data is in XML format (see below). I can extract the data I need via the CAST function, but looking to see if there’s a more efficient query to do so. The data below exists in the details
How to count each value with the same id in sql
I have a table like this How can I get the count of all values with Poll_id = 1 so I can get using sql Answer Use group by with where:
How does SQL subqueries use outside variables
select sName, GPA, sID from Student S1 where not exists (select sName from Student S2 where S2.GPA > S1.GPA) Say the above query. How does the following line work? (select sName from Student S2 …