I have a problem to solve. First I split this problem into parts and so I wrote four queries separately but now I need to put them together as if it were a single call to return a single result. How can I do this? 1) I select purchases according to branch and store 2) I validate if the promotional
Is there a way to show only the top 2/nth of a query after “group by” country? – bigquery SQL
I am doing a query on Google Big query, I have joined the 2 tables and created a new column “total gmv” using “SUM” to represent the total revenue, now I wanted to show only the top 2 vendors , GROUP BY country in my query. I manage to show total_gmv group by COUNTRY and vendor_name, b…
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
Trigger to check if the combination of two field exist
I want to create a trigger which will check if my showtime with Cinema Hall Id exist or not. This will prevent me from booking one Cinema hall at two same Showtimes. Secondly in this trigger I am also checking if the showtime I am assigning to movie lies in movie release and last date range or not. But I
ASP.NET Core display all rows in database on page
I am trying to display every row from a database on a website with ASP.NET Core MVC, but I cannot find any source on how to do it.. This is what Ive tried to do but I got stuck: My Database is structured like this: Id, Username, Password, PasswordHash, but I only want to display Username to begin with. If
How to select only one row if a value of a column occurse multiple times in the result?
I have a table like this on: AttributeA AttributeB AttributeC AttributeD A B EQUALITY D 123 B EQUALITY D 456 B C D … … … … My goal is, to create a Select-Query where the result only contains one row with an equal AttributeC – no matter of the count of rows with the same value in …
Adding a column to an SQL table and exploding the rows with a set of fixed values for that column
I would like to add a column to an SQL table with unknown columns and explode the entries in that table by a set of fixed values for that column. E.g. Turn unknown col 1 … unknown col x 1 … foo 2 … bar into unknown col 1 … unknown col x new col 1 … foo 1 2
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