I have a database with a structure of: I am struggling to write a query to show me where ‘Supp’ is different. (Supp Should be the same for all records, So i need to identify records effected to correct) The table contains more than 55,000 lines Just a list of Codes where Supp is not the same for e…
Tag: sql-server
How to Group By in SQL Server Query
I’m using this query to get the Sum of SaleAmount for each type (SOType) of Sale Invoices. I am getting the result but the result is not grouped by SOType. Have tried to use Group by Outside the query …
How to select MAX from AVG?
I’m practicing for my SQL exam and I can’t figure out the following question: “Of the average amount paid per customer, show the highest amount.” So to retrieve the average amount paid, I would do the following: Then I would like to retrieve the highest average amount out of this list …
SQL computed column based on a special character on another column
I am not good with SQL at all, barely have an idea on how to do basic scripts suck as delete, drop, add. I have this data with about 12 columns, I want to add a calculated column which will change depending if a special character shows up in another column. lets say that is the idea, I want to
sql server – How can I put the values in a result side by side
How can I put the values(RESULT) in a result side by side How can I do it? –> Set @DomainName = ‘marka.com’ @DomainName = ‘marka.com’ –How do I add Answer
Find users with most number of common pages they liked
I am trying to find pairs of users who liked the same pages and list the ones who have the most common page likes at the top. For simplicity I am considering the following table schema Likes (…
Grouping By Date When Used In Case
I’ve got a working query where I can export to Excel and pivot myself to not be grouped by the fldTrancationDateTime column and that is working fine as a short term solution. Is the only option here to use SQL pivot so I can only group by the Product and have each date range populated? Instead of one ro…
Get data from other table based on column with concatenated values
I have two tables: category with columns: article with columns: I know there should be a separate table for article categories but I was given this. Is it possible to write a query that returns: I thought of splitting the string in article -> categories column, then use in query to extract name from catego…
Transposing Column Data into Row Data SQL
I have some data that looks like this in an SQL table. [ID],[SettleDate],[Curr1],[Curr2][Quantity1],[Quantity2],[CashAmount1],[CashAmount2] The issue i have, i need to create 2 records from this …
Merge records that have at least one non-null element in a specific column – SQL Server
My data looks like as following: id ProteinID Gene_Name Class 10008 P08648 ITGA5 extracellular 10009 P08648 ITGA5 extracellular 10011 P08473 MME 10 NULL …