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 …
Tag: sql
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: …
SQL Pivot on Conditional Count
I have a table of vulnerabilities using SQL server, when I perform the following query select * from table The output looks like so. | Name | HostName | Week | | ————- |——-…
How I can update one to many relation in Postgres?
Here is my first table question. Questions have many options, so I referring every option row with question_id Now, How can I update both tables in one query? I building an API. The below-given output is for request. The request will response with question details and options for the question. I am able to up…
avoid explicit cast to float?
Can SELECT CAST(2.083 AS float) AS c be written in a more compact way ? Something like SELECT 2.083f AS c ?