I have 3 tables in SQL Server storing data for every execution of SSRS report Subscription Catalog Users : default table for employees in the company I want to get the following information : …
Looking for the same Trader buying and selling the same product within the 3minutes
Below I’ve the example table Create Table #A ( Time nvarchar(70), Trader nvarchar(30), Product nvarchar(30), [Buy/Sell] nvarchar(30) ) Insert into #A Values (‘2019-03-01T14:22:…
How to have data in Range column
I have 1 table named Temp1 and Columns are as below. In this table we have to make sure that salary of employee for any designation must be in between TopRange and Bottom Range. So I need to create a …
Postgresql constraint violated at restore
I have a problem with a constraint that is being violated by some rows when restoring my DB, but has never been violated at usage. I have 3 tables : some_table here is another table, which I think is not relevant for this problem. Now what I want is to have a unicity constraint between as.id and bs.some_id th…
Query that will result in a list of customer names and the average order value made by each customer
I have a database and I need to create a query that will retrieve a list of customer names and the average order value made by each customer. I tried: SELECT c.customer_name, AVG(COUNT(o.order_id)*f….
How to create a column in SQL containing using the AVG() function?
I have a table with one column and 46 rows and I want to create another column that contains the average of the first column in all 46 rows e.g. This is the table: I want to add another column that contains for each row (46 rows) the value of AVG(column1) How do can it be done? Answer You wouldn’t
Create subqueries for each value in a Column
I’m looking to create a SQL query that answers the following question: “Which was the most common destination airport in each month?” The table is structured such that it has Month and Destination_Airport columns (amongst other things), and I’m hoping for the query result to look like …
Remove duplicate rows from a big table
I’ve got data from third party and imported to SQL server. The table has 255,072,636 records and 61,714,772 are unique among these records. The table has neither specific order nor any index. The table has 4 columns: Field1(float), Field2(varchar(255), Field3(varchar(255), Field4(varchar(255). I want to…
Order of Procedure for Select statement with Where Clause and other operators
This is the table I’m working off: From this order of procedure that was provided in class: Parentheses */ +- = <= >= < > IS Between NOT AND OR I have to work out how many rows of the following statement with show up: Is this statement read in this order: QtyA+QtyB QtyA+QtyB < 5 gender = …
Unexpected results with consecutive + and – [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I have the following queries : The result is : How is this output explained…