I have a table that looks like this: There are 400,000 rows. The ActivityNumber is a unique ticket number with the activity count attached. There are 4 teams. Each activitynumber is in the table. I need to calculate the average time taken between updates for each team, for each month (to see how each team is …
Tag: sql
Pyspark: cast array with nested struct to string
I have pyspark dataframe with a column named Filters: “array>” I want to save my dataframe in csv file, for that i need to cast the array to string type. I tried to cast it: DF.Filters.tostring() and DF.Filters.cast(StringType()), but both solutions generate error message for each row in the co…
“ORA-00907: missing right parenthesis” during inserting into table
insert into eas_citizen_text_info values(690102355714,’male’,’Shailendra’,’Baliram’,’Torane’,(‘1995-06-02′,’yyyy-mm-dd’),21,’Bauddha’,’Single’,’Building no-E9, Room no-23, Rajarshi Shahu Nagar,…
Convert columns to rows in Firebird (unpivot command)
Which is the similar command for unpivot in Firebird? TKS in advance… My Table Desired Result Answer You can use union all: Something like this should work for most purposes. EDIT: For your particular data:
Get most recent row with group by and Laravel
Even though there are multiple questions like this I can’t get my query to return the row with the most recent date with a group by. I have the following table.. | message_id | from | to | …
How to get percentage of rows which are not NULL in a specific column?
I have a database setup like this: Table called reviews How do I get the percentage of how many rows there are, which are NOT NULL? A basic “formula” of what I want: percentage = 100 * ( (Sum of rows where review is not null) / (Amount of rows) ) For the example above, this would be: percentage =
Bulk insert using EntityFramework Extended
According to this, bulk insert in Entity can be made using the following code: I used SQL Profiler to verify how many insert queries were executed and I saw there was an insert for each element of the list. Why? Answer AddRange Add range doesn’t perform a BulkInsert, it simply DetectChanges once after a…
TSQL find number of correspondences
I have the following table: Test Data: I need to find out how many times correspondence has been between each pair. For example, Anthony has contacted John 5 times, John has contacted Anthony 5 times. So total correspondence between John and Anthony has been 10 times. Similarly, David has contacted John total…
Create SQL Server table from user-defined class [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last month. Improve this question I am creating a mini-ORM to learn reflection better in C#. Also I want…
Using distinct with stuff/for xml path(”)
I’d like to put together only unique values in the concatenated string. My code is currently: This gives me the output I’d expect, but I would like to eliminate the duplicate values in the stuff/for xml path field. I’ve tried various combinations of distinct and group by in the stuff/xml sec…