I’m trying to retrieve the raw SQL generated by Entity Framework for the following LINQ query: pagedItemResults = from firstItem in dbData.Accession join secondItem in …
Tag: sql
Oracle – Find the group of most consecutive occurrence of a value in a column
I have a table structure called test_table like this: and so on.. It is a large table and has about 3000 rows. I want to find the section of the table (start and end timestamp) for the longest running occurrence of “C” values. For example in the above case it would be 8:46:59 to 8:48:55. Is there …
How I can retrieve all data from the first table and some of the second table
I have two tables and the relation between them are NO. . How I can write SQl query to give me output form table1 and table2 only for who id is 5050 and the output should be like this Answer This is an example of a LEFT JOIN — keeping all the rows in the first table but only matching
ST_Distance_Sphere in mysql not giving accurate distance between two locations
My requirement is to calculate the distance between two locations on a given map using mysql. I found a function in mysql named ST_Distance_Sphere which returns the minimum spherical distance between two locations and/or multi locations on a sphere in meters. When I computed the distance between two locations…
SQL Server – How many rows have been inserted into a table while a query is running?
I’m running a cleansing script that has 10 unions and results in, more or less, 1.2 billion rows (I’m re-executing this script including some missing fields, so I know and expect this number at the end of the execution). I’m inserting this cleaned data into a new table (X). I’ve made s…
SQL Stored Procedure Select Multiple Rows and Insert Into Another Table
I know this question may sound like a duplicate, but I searched and couldn’t find a good answer yet. I have a stored procedure (started) that looks like this: The problem is the Select returns multiple rows and all of them need to be inserted into the other table. I’m really just not sure where to…
Filtering a Pyspark DataFrame with SQL-like IN clause
I want to filter a Pyspark DataFrame with a SQL-like IN clause, as in sc = SparkContext() sqlc = SQLContext(sc) df = sqlc.sql(‘SELECT * from my_df WHERE field1 IN a’) where a is the tuple (1, 2, 3). …
How do I get the column name of a foreign key reference in PHP
I have got two tables: category and quiz In category I have : category_id | category_name | In quiz I have : quiz_id | quiz_name | quiz_category_id| quiz_duration As you can notice, …
Can only find table in Oracle SQL when surrounding the table name with double quotes. Why?
I’m having the following weird issue with Oracle SQL. I have a table called schema_version, but I can’t run simple selects over it: > SELECT * FROM schema_version; ORA-00942: table or view does …
What is this query supposed to do? (and why does it fail?)
I’m tasked with revive this old piece of legacy software. It used to run on an old server (2012) which has died the ugly way (hard disk failure). Before this server died, the code worked without problems. I’ve rebuild the MySQL database and data from backups. However, one query is does not work an…