Skip to content
Advertisement

Tag: subquery

Extract the record for last hour for specific date

I am trying to extract the last hour (TKT_DT) record for number of tickets (TKT_DN) from sales table (PS_TKT_HIST) for specific date (BUS_DAT). I have the following code but it extracts the number of tickets (TKT_NO) for each hour. I want to filter the last hour only. Here is the code I used: I get the flowing results I want

Using a subquery in a case statement in a where clause

I want to select different results (from a temp table) based on what a certain parameter is set to in the query. I want to exclude certain inventory SKUs if a particular warehouse is selected. I am getting this error, unfortunately. Msg 512, Level 16, State 1, Line 310 Subquery returned more than 1 value. This is not permitted when

Getting different results from Subquery and JOIN which seem to be the same

I’m doing a challenge problem on DataCamp. It uses two tables, “economies” which contains economic information by country code, and “countries” which contains general country information by country code. The challenge is: Get country code, inflation rate, and unemployment rate in 2015 from the “economies” table, where the gov_form is not ‘Constitutional Monarchy’ or ‘%Republic%’ in the “countries” table. With

SQL – Ordering table with subquery for select

I am trying to do ordering on query with subquery for a name from uuid. Let’s have those two tables in MySQL: bans: id uuid time reason 1 c6b8eade-7db9-345b-b838-8f8361552cf5 1642369382 Test 2 0138c279-c5fa-3acd-adaa-8edb7b4569d8 1642384565 Spam 3 3c01262c-a3c3-3133-ba43-92a9ded01c27 1631876477 Hax users: id uuid name 45 c6b8eade-7db9-345b-b838-8f8361552cf5 John 100 0138c279-c5fa-3acd-adaa-8edb7b4569d8 Mike 35 3c01262c-a3c3-3133-ba43-92a9ded01c27 Norman With this query, I can select whole ban

Find the number of employees working under a manager

I have three tables called branch,employee and manager structured like this I want to view the id of each manager and the count of the employees he has under his supervision like this I have made this so far that shows which branch each manager works on but i don’t know how to proceed with the counting. The solution i

Advertisement