Here is a link to a sqlfiddle with sample data: http://sqlfiddle.com/#!18/d8d552/3 I’m trying to delete 1 row from rows that have the same values in both name and color. If they have they same score, then it doesn’t matter which one is deleted. If those rows have a different score, then I want to …
Tag: sql-server
Create view with JSON array based on many to many table
I have a typical table with users. I have also a many to many table where first column is UserId and second BusinessId. I want to create a view with users where their businessId will be as json. I tried something like this: But in view I get this: Id BusinessEntityIds 1 [{“BusinessId”:1925},{̶…
Query to return all values from next month
I have a dataset of subscriptions in a table that looks something like this: Table: UserID Subscription_type Subscription_end_date I’m trying to build a report in SSRS that shows a list of all subscriptions that are going to expire somewhere in the next month. The report gets sent on the first of every …
SQL: How can I pick a cell value from one table as a condition to select another table
Hi I’m a new learner of SQL. How can I realize this process in SQL or perhaps with python if needed: First, from table1, I randomly selected two results: I need to use the value x and y as conditions to display another table. For instance, using x, I can: What I need is to get the length of table2
Renumbering A Column Based On Other Columns
This table contains Purchase Orders which can have multiple lines per order. Right now the table appears like this. Purchase_OrderNumber Account_Number Line_Number 174558 0000448 1 174558 0000448 2 175812 295812 1 175812 295812 1 175812 295812 2 175812 295812 545 175812 295812 26686 175812 295812 53481 175813…
Finding orders placed between two times gives zero result
I’m not sure what’s happening here. I’m trying to select the orders that were placed between 4PM and 4AM, so from 1600 to 0400. The date does not matter, just the time. This is what I’ve tried so far. Here is the code for the table: I selected using several ways: I keep getting nothing…
Distinct few Columns and check condition on the column not included in distinct columns
Table “Module” has these columns How to select distinct columns of ModuleGroupDisplayAs and ModuleGroup And After that, Add column on checking these distinct columns has particular UserID and CompanyID. That means I want to check condition that distinct columns has this particular userID and Compa…
how to read a XML string value with leading space in sql server
I want to store the value of userId as ” XYZ” but when after executing the below code got output as “XYZ”. Want to store the value with leading space. Answer You may try to parse the input XML using a variable of XML data type and a combination of nodes() and value() methods: Using thi…
Show a string that contains two numbers in SQL [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 I’m studying SQL just recently and I have encountered a problem. I want to show the Addr…
Error converting data type varchar to bigint: INSERT INTO SELECT
I keep getting this error when trying to execute a stored procedure and am not sure why: Msg 8114: Error converting data type varchar to bigint. Please see my SQL query below: I believe the error is emerging because of the UniqueStudentID I have tried using CAST & CONVERT around the SELECT line but still …