Skip to content
Advertisement

Tag: union

SQL Query — AVG for Occurrence Across Multiple Columns

I have a table like the following ID_A ID_B Avg_Class_Size 1 2 16 3 4 10 2 3 8 2 4 9 Where ID_A and ID_B represent distinct student ID codes, and AVG_Class_Size represents the average class size of the classes shared between students A and B. I would like to calculate the average of the “avg_class_size” for each student,

sql – union tables with same prefix

I have a set of tables with same prefix and same structure. All I need is to “combine” them as one. Basically I retrieve tables with certain pattern from information_schema.tables, then get rid of the last union all. Above method works for 20-30 tables, as the @result won’t exceed the limit for nvarchar. But I’m curious how to get this

Consolidate SQL Union With JOIN

Let’s say I have 2 tables (bar_helper and bar). I have a query that retrieves records based on a JOIN between the tables and some condition. Essentially, my first result set is joined and I want my second one to be unconditional and just based on one table. This works fine. However, now I need to also get a second

Unpivot Data Using MS Access Query

Hoping someone with Access & SQL experience would be able to write some SQL code that I could use in MS Access to transform/unpivot some data. I’ve spent a day trying advise from others who have asked similar questions here, but I have no SQL experience and have failed miserably so far. Answer You can use union all to unpivot

SQL – Snowflake Minus Operator

Hi I am running a query to check for any changes in a table between two dates…. The first select statement (where run_time = current_date() return 3,357,210 records. The second select statement (where run_time = current_date()-1 returns 0 records. Using the MINUS operator, I was expecting to see 3,357,210 records (3,357,210 – 0) but instead I get 2,026,434 Any thoughts

Return in which or statement results are from SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I’m having the following SQL statement, to return worksheets that teachers have liked, and worksheets that teachers made by themselves. It’s working fine, but now

What is the type casting hierarchy in mysql?

Taking the following example: If I only include the first select statement in the cte, the type will be int. If I include the first and second, the type will be DECIMAL, and if I include all three, the type will be cast to VARCHAR (regardless of position of the three statements). How does mysql determine which type to cast

Advertisement