Skip to content

Tag: sql-server

Joining another tables results to add to a existing query

I want to add RuntimePercentage column to my existing Uptime query for a report. Below is the current queries I use now. To do this I need to join another table results to make it happen but I haven’t been able to find a solution. The where clause gives me a error because UptimeMin is only in table a. H…

Adding Variables to SQL queries

I have the following code which returns a table from my ms sql Database How would I add the one_yrs_ago variable to the SQL query in this situation , like so : Answer Not seeing the full context but this is how I would do it in SQL Server I would say parameterize what you pass in is important as

SQL GROUP BY with LEFT JOIN MS SQL Server

I have a calendar table (c) with a set of 3 month dates: I have a Stats table (s) with views of each product on the website. I need to count the views per product per month whether there are views or not. I have followed many SO answers (SQL – Group By with Left Join) and I cannot see

Delete records with duplicates and join in another table

I need to write a query (Microsoft SQL Server) to delete duplicates in the table Vehicle that have Vehicle.CarId = Car.CarId and having the same concatenation (CarId, CounterLimit, Kilometers). Table Car: Table Vehicle: Could you please help me? Answer Joining the table creating the rank based on carid,counte…

Comparing two tables without foreign key [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 last year. Improve this question There are two tables in 2 different databases one table consists of Salutations example Mr, Mi…

How to convert XML type return text into select columns

I’m trying to get the column names of a table using XML datatype and information_schema columns. When I tried to use the result in another select statement, I have the results with the repeated column name instead of the results set. I have even tried to cast it to varchar but it still failed. what have…