I have to create a new column in my table called Raise that has a 20% raise from the values of the SAL column, here’s what I have so far: SELECT ENAME,EMPNO, JOB, SAL from emp ALTER TABLE emp ADD …
Quickest way to import a large (50gb) csv file into azure database
I’ve just consolidated 100 csv.files into a single monster file with a total size of about 50gb. I now need to load this into my azure database. Given that I have already created my table in the …
How to avoid rails as_json creating flood of database requests
I have a model questions that has many tags through another model question_tags. I am trying to write an api endpoint that returns a list of questions and for each question a list of it’s related tag’s name and id. I’m currently using; But this runs a separate db request for every question i…
Invalid Object Name – Tried a few things
I have the following query: It keeps telling me ‘invalid object name’. The table exists. I checked the drop-down to ensure the right database is connected. I refreshed Intellisense cache. Not sure what else to do… Answer I think you are looking for linked server object names, if so then you …
Better way to write a multiple case statement SQL
I have this query bellow. And I’m trying to find a better way to write this query that has a statement. I don’t want to store each case value in a temp table, but maybe in an array.. Any input? Answer Does IN satisfy what you want to do? It certainly shortens the code.
A query to update group of related items with their main primary key (parent keys)
I Need to update the TS_PARENT_TS_ID column with the TS_ID column(Primary Key). Using the first rowas example, see column name (TS_TERM_TYPE_NAME), You have “MAIN” directly under it is “RELATED(s)”. all of which are related to each other, hence should have the same foreign keys in colu…
MySql Trigger for notification
In a table in MySql database, I have a boolean column with ‘Yes’ and ‘No’ for appointment confirmation. As soon as appointment gets ‘Yes’, a notification is sent via an AWS Lambda call. I want to send a 12 hour prior notification before the day of the appointment. What is t…
Django ORM filter multiple fields using ‘IN’ statement
So I have the following model in Django: My goal is to have all the tuples grouped by the member with the most recent date. There are many ways to do it, one of them is using a subquery that groups by the member with max date_time and filtering member_loyalty with its results. The working sql for this solutio…
SQL Update with COUNT(*) less than 2
I have two tables to query from. An “Order_Details” table and a “Product” table. I need to COUNT(*) the amount of times each product has been ordered(identified by unique a “ORDER_ID”), from the “Order_Details” table. If the amount of times a product has been or…
Finding highest reached threshold
I have a table that contains 2 columns that store values of certain thresholds that can be reached. The table columns are: ThresholdValue (INT), Reached (BIT) and the table looks like this: …