I have set of vehicle parts stored in two tables as per below: Source Table1: Vehicle_ID Part1 Part2 Part3 Part4 Part5 1 10 20 30 2 10 20 3 10 Source Table2: Vehicle_ID Part6 Part7 Part8 Part9 Part10 1 40 2 30 50 60 3 30 Required Table like below: Vehicle_ID Part1 Part2 Part3 Part4 Part5 1 10 20 30
Tag: sql-server
Azure SQL: Modify table data via UI instead of writing SQL query
Is there a way I can modify the table data in an Azure SQL database via some sort of UI (like Excel) instead of having to write SQL queries? Preferably I can modify it online in the Azure Portal instead of having to install some third-party software. Often times, I just want to edit a specific cell in the table
Assistance with PERCENTILE_CONT function and GROUP By error
All, I am having problems with the below query. I am trying to get stat data from our database for the last 3 years but I keep getting the error message: ***Column ‘OC_VDATA.DATA1’ is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.*** I know it has something to
How to handle NULL values in WHERE clause and change target column based upon its encounter
I need the WHERE clause to change what column it is evaluating when NULL is encountered. For instance I’m trying to do something like this: Is something like this possible? One of the 3 cust_id’s will not be NULL. Answer That seems like less than optimal table design, but isn’t a simple COALESCE where you’re after?
Return distinct results that appear more than once
I have the following data: Result should be: Note that the result find unique combinations of ID and Site that repeat more than once for a given ID. I did the following query but does not return the result: Answer See: DBFIDDLE The SELECT ID, site FROM table1 GROUP BY ID, site will select the distinct values. Then, using HAVING
query to get statistic data from SQL server
I have a table named total sales. In this table there are sales data like invoice date and branch name that sells the invoice and the quantity. I am trying to make a query to get total sales for each branch in every single date and my code is below, but when I execute the code the query returns an
How to create a constraint on custom datatype in SQL Server
I want to create a custom datatype in SQL Server with some sort of constraint that checks and validates the type by running through a custom function and returns an error if it fails. For example I have some sort of a Hebrew calendar in SQL Server, with a function that converts from a Hebrew date to a Gregorian date,
How to count the number of a value in each month and year? SQL
how can I count the number of ‘cancel’ value in each month and year? Thank you! MS SQL expected output: ETC…. Answer You can start trying something like this: The column [date] should be datetime. If it’s text you will have to cast it:
How do I insert multiple rows with many to many relations into ‘Table1’ from ‘Table1’?
I’m trying to copy an existing ship, with all of its contents of its child tables (for lack of a better term) and their relations. So far I’ve got most of the copying down except for the ship’s tables that have a many to many relation. An example of my current situation is as follows: I have two individual tables
In SQL, how do I filter a parent with its child records if either satisfies a condition
I have the following table as example. I want to retrieve only the records where the ScheduleDate is smaller than 2022-01-03 (Jan 3, 2022) for either the parent and child records but I want the whole family only (parents and children together). With this set of records, the results should return the records 1 to 9 only. ScheduleId 12 does