Skip to content
Advertisement

SQL: Creating quarter values based off conditional statements

I have the following table: jan feb mar apr may jun jul aug sep oct nov dec 322 44 1222 These are invoice amount columns. They’re based off of the months of the year. What I’m trying to do is make a new column called execution window that will have different quarter values depending on where the amounts show up

Grouping columns to find most popular product for each country

I’m a SQL beginner, practicing through various sources. I have a table called marketing_data containing product sales information, country and other variables where I’m trying to get an output for the most popular product per country, based on sales. I don’t know where to begin with my syntax. This is how the data looks in the table I’ve previously run

Pass Parameters in Pivot SQL

I had this query below and got an error with parameter @emp_group during execution. Need your suggestion on how to pass the parameter. The query will run when removing the parameter but need to filter the records. thanks in advance. Answer You can can do the same thing with @emp_group like you did with @cols. Extract them vom the text

Combine rows by consecutive timestamp

I have an input table as below: name time price one 2022-11-22 19:00:00 UTC 12 one 2022-11-23 7:00:00 UTC 24 one 2022-11-23 19:00:00 UTC 10 one 2022-11-24 7:00:00 UTC 20 My expected output is: name time price one 2022-11-22 36 one 2022-11-23 30 Explanation: I have to group-by 2 consecutive timestamps, the prev date 19:00:00 UTC and the next date

Advertisement