Tables: Sessions session_ts visitor_id vertical session_id Transactions session_ts session_id rev_bucket revenue Currently have the following query (using SQLite): I’m having trouble identifying the first two sessions that combine for $500. Open to any feedback and simplifying of query. Thanks! Answer Y…
Tag: join
MYSQL getting data from three tables
I am trying to find the drinker and total amount of money spent on drinks for all drinkers in February 2020. I also need to include drinkers who haven’t ordered a drink in this period. Here are the three tables: Here is my statement so far: I am very new to SQL, I know that there are a number of
How can I translate this SQL code to R script using dplyr?
I’m currently working on a project and I want to summarize a column from a joined table twice. SQL code is this: …and the result is this: Database tables are as shown here: I hope that I have provided all the information needed. Question: How can I have the same result in R by only using dplyr lib…
MySQL (Laravel Eloquent) – Get record when two columns have two or more values at the same time
I have this database that I got from this post that manages products and its variants: The problem is, that I don’t know how would I get the SKU at the moment that a user selects the options of the product he wants: Let’s suppose that the user selects the product with ID 1 and the options size-sma…
MySQL conditional querying many to many relations (inner joined tables) from an array
I’ve a colors table and an items table, with a many to many relation between these 2 tables (via an items_colors table). An item can have many colors and a color can have many items. From an array of colors, I would like to get all items that only match one or more provided colors. If an item is also
SQL Collect duplicates to one place? PostgreSQL
Sorry I’m new here and I’m also new with SQL and can’t really explain my problem in the title… So I have a TV show database, and there I have a Genre column, but for a TV show there are multiple Genres stored, so when I’m selecting all my TV Shows how can I combine them? It needs…
Select based on multiple ID’s in the same column
I have two SQL tables already built (not by me) : One table that has all the ingredients with ID’s assigned to them : and the second table that has finished products that have reference to ingredientID in the ProductIngredients column but no the product name and they are built like this : If they don…
SQL Server query duplicating rows based on inventory locations that have been claused out
My current code is duplicating results per item_id. I am summing the previous three months usage per item in two locations. I do have more locations but I limited it in the WHERE clause. I think the …
what is the query in oracle sql to find product orders before a certain date?
how do i find all the customers who have made orders before 2017. List must incld the customer ID, customer name, and ordered by their ID values in desc Answer You can use exists and a correlated subquery to filter customers who ordered before 2017. We can get that information by looking at the orders table o…
Map results from one table to different columns in another query
I’m trying to retrieve a set of records from table that has descriptions on another table in same database. Table 1: ColA1 | DescrpA1 — A – – – – Apple — B – – – – Orange — C – – – – Banana — D – –…