Skip to content

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

Laravel Query Builder joining with alias

I have two tables Unknown table Clients table My Code : Joining will be with the clients.id => unknown.parent_id… As because the clients table has a parent_id that’s why i have to use the alias Please Help me to do so! Answer Using Alias Working Solution:

Set prefix in SQL CASE expression

I have problem setting a prefix in a case statement. Data set: When I run this query my result is this: Desired result is this: As one can see, the first zero is not shown in the result. How can I achieve this? Answer CASE expression would always return one type so, you need to do conversion:

Save value from last year in current table

This is a more general question about database designing. I am currently migrating an Excel/VBA program to SQL and got following situation where i need food for thought, as i am doing this the first …