So I try to print a message when I have any confirmation or error. I have this table [Friendship] that have the ID, friend mail, their mail and the date that have been confirm the friendship, Table without data When I use the EXEC for this PROCEDURE, I have the insert values, but not the print´s acctions̷…
Syntax issue with CTE to Pivot function
I’m having a problem getting syntax correct from variables to CTE to Pivot. I’m capturing sp_whoisactive to a table and am now aggregating CPU and Duration by Region. I then want to pivot those …
Get yearly average of per id
This code gets the number of ids that that show up for each month with in the year. This is the result i get: I want to get the yearly average of each ID, and the overall count. The results will look like this: Answer You can add another level of aggregation: Notes: you don’t actually need a CTE to
Mysql Json extract with conditional filter
I’m trying to query some json data through a filter. Given a json array like this: I’d like to select all the rows which have as country name ‘France’ and a value greater than 10 as ‘people’ ONLY in objects which have the property name set to ‘France’. Would it …
How to change column charset, set as not null and add a default value?
The column contains some rules such as not nullable and character_set_name is latin1 and I should write a query to update only the character_set_name. field: name type: varchar(255) null: NO default: JACK character_set_name: latin1 Is there any way to do this in one query? if I run only the first query, ̵…
SQL: Return Column Name With Highest Value From Subquery
Working with a large data set in Big Query that assigns a specific grade to an item. For example: To summarize these, I wrote out some COUNT & CASE functions, like: It results in something like below: I have been attempting to have this computation happen in a subquery, and then use the alp_a or org_a to …
Extracting multiple values from BLOB as XML
I have an XML like this in a BLOB column: As you can see the year can be either in the event level or at country level. There can be multiple events and multiple countries per event. This whole XML is stored in a BLOB column in Oracle. I need to extract the value of the year or better check
What is the bad in running multiple commands in the same query
I am using Sql-Server and Postgresql, usually when I need to run multiple commands, I open a new connection, and foreach needed query task I run a command (inserting 1000 rows, for example). Is it bad if I run multiple query commands in a single command(queries separated by comma) vs previous behavior? Answer…
Use the value of an attribute from another table as a default value of an attribute from another table in MYSQL
I wanted to use the value on student_lastname in table tbl_student as a default value of sis_password in table tbl_sis_account but I am out of idea on how to do it. I tried putting “Select query” after the “Default” but it doesn’nt work, anyway here’s the sql: Answer I̵…
how to Update an empty table with the result of a query
i have a table name average rating. i want to update my table name final rating with the result of this query how can i do this? Answer Maybe something like or if the FinalRating table contains more information you could also specify the columns you can also add a where clause to either query if you need a su…