I have close to 100 tables and a lot have very similar names, beginning with names like ‘STANDARD’ and ‘MARKIT’, and so on and so forth. I’d like to find all column names that are the same for these …
SELECT Records From Child Table That Are Not In Another And Parent Has No Other Children
I’m trying to write a query to select all orphan records that are in a child table, but only when orphaned records are the only items in the table. I have two separate databases from separate systems,…
Query to display top rated artist albums in MS Access
I have two tables in a music db. [Artists] has PK artist_id and artist_name. [Albums] has FK artist_id, album_id, album_name, and rating. I want to select MAX(rating), album_name and GROUP BY [album]….
Sum with SQL depending on the value of a column
I have 3 columns : year, price, and day_type. year day_type price 2016 0 10 2016 1 20 2016 2 5 2017 0 14 2017 1 6 2017 2 3 I want to keep only the lines where day_type = 1 or 2, but add to these …
Simplifying CASE Statement with Correlated Subqueries
Can I simplify the below CASE statement, which runs the same correlated subquery twice? CASE WHEN (SELECT val1 FROM t1 WHERE out.id = t1.t1 AND …
Extracting Data from SQL Server Table within a Schema
I am having a hard time writing and extracting data from SQL Server in RStudio. My database hierarchy is as follows: LDS LDS HIG table_needed I’ve tried: ch <- DBI::dbConnect(odbc::odbc(), "…
How do I select birthdays in the next 30 Days
I have a table with birthdates and I want to select all the birthdays that will come in the next 30 days. The situation is, that all the birthdays are written in the form off 1999-09-15 which means that even if I tried selecting the next 30 days, the birthdays wouldn’t show up because the year is 1999. …
EF Core integer field contains substring efficiently
In a SQL Server database table, I have an integer ID column. This is not a primary key, more like a serial number. I don’t have the ability to change the table definition. I have a requirement that …
I am struggling to remove the last 30 characters from data in a column
I am looking to remove the last 30 characters from a colum within my database. I have created the below which works in the sense it shows me the result and it’s correct but it does not commit or change anything. What am I missing, I am a noob 🙂 I expect the data in the column to remove the
Executing multiple drop table statements in 1 sql file
I am trying to drop 200 tables from my database and save the sql statements to 1 .sql file so they can be run in one go on each copy of the database. I would like to use a separate drop table statement for each table so I can easily reference what line any errors appear on. I have tried