Skip to content

SQL syntax to achieve the “opposite” of LIKE

I’m very rusty on the little SQL I once learned, and while I totally get SELECT column1 FROM table WHERE column2 LIKE pattern, what I need is: For example, I might have a product family table which has information about the Coca Cola range, and for which I might store coca% in column2 ready to match spe…

Select Distinct Records and count other columns related to record

I am trying to create a SQL Query wherein it will pick all distinct records from the first column and do a count of all the items related to that column similar to a countifs command in Excel. I am new to SQL and I am really lost at this point. please help. Sample Table: Employee Item Weight EmpA Red

SQL Server 2016: how to get a single row view

I have been trying to word this correctly, but here’s my dbfiddle Table: Expected Output: CustomerKey processdate Product_Mix Product_Mix_Expanded 101 2021-05-01 12,3,5 CCcount, CHKCount, SACount 102 2021-02-03 1,3,1 CCcount, CHKCount, SACount 103 2019-04-12 4,0,2 CCount, SACount As you can see, I used …

Count of all occurrences on all rows

I need to complete an overall count of occurrences of one column and all rows. As an example of data: How many times the place has occurred. I’ve done this so far which counts the years but how do I then do a count on that count So how do I now count my places by the year counts? For