Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
I need to collect the name and total order of customers who had an order of more than 56000. there are three tables, customers, orders, and orderdetails.
This is the output that I need:
this is the code that im trying:
select a.customername, sum(c.priceeach*c.quantityordered) as "ORDERTOTAL"
from customers a
join orders b on b.customernumber = a.customernumber
join orderdetails c on c.ordernumber = b.ordernumber
having sum(c.priceeach*c.quantityordered) > 58000
group by a.customername;
but it is giving me 76 rows.
when I only try with the table order details i can get exact 7 rows but the table orderdetails doesnt contain customername, I can't undrestand where am I doing it wrong.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
As the title suggests, trying to take the count or possibly distinct count of a column, we call it year, to count the number of a years for an individual or populated ID and place it another column in the same table. Here is an idea of what I have so far and we want to update the table. Thank you.
Join group table to updated table directly:
UPDATE outputtable O JOIN
(SELECT personID, COUNT(DISTINCT year) AS countYear
FROM outputtable GROUP BY personID) temp ON O.personID=temp.personID
SET O.N=temp.countYear
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
[![table named teams and Matches ][2]][2]I have 2 tables
[2]: https://i.stack.imgur.com/7v4nT.png**strong text**
I need data from these 2 tables in such a ways that a new table is formed with the following data
mid, result, date, team1id, team2id from matches table on the basis of tourid=6 and from table of team i need to show the Tname as team1 and Tname as team2.
Sounds like you need a join:
select matches.*,t1.Tname as team1,t2.Tname as team2 from matches
join team t1 on t1.Teamid=matches.team1id
join team t2 on t2.Teamid=matches.team2id
where tourid=6
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a simple entry in the oracle, there are 3 columns, date, API name and status. I want that in the answer I had not all history, and only the last on each of Names of API (only 7). I will be grateful for your help. I know that asked of the very difficult but I'm just new to oracle.
select l.log_date,l.job_name,l.status from user_scheduler_job_log l
could be you want the related status for name and last log_date
select u.job_name, u.status, t.max_date
from user_scheduler_job_log u
INNER JOIN(
select MAX(l.log_date) max_date, l.job_name
from user_scheduler_job_log l
GROUP BY l.job_name
) t on t.max_date = u.log_date
AND t.job_name = u.job_name
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Have a common schema, with two tables.
users table contains the columns id, name.
checkins table contains the columns user_id, checkin_date.
in this hypothetical, users can have many instances of rows in the checkins table.
checkin_date in this case is of type date
I want to be able to query for all users who have at minimum 1 checkin in the checkins table where the checkin is after 2016.
I would suggest using exists:
select u.*
from users u
where exists (select 1
from checks c
where c.user_id = u.id and c.checkin_date >= '2016-01-01'
);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have this two following tables:
Order Table
Product Table
I'm trying to calculate the subtotal price for each product (quantity*price) then SUM the TOTAL value for the entire order.
Thanks, Any help would be very appreciated.
Check if table names are correct and try this:
SELECT o.order_number, o.item_quantity, p.price,(o.item_quantity * p.price) AS subtotal, SUM( o.item_quantity * p.price) AS total
FROM order AS o
LEFT JOIN product AS p ON product_number = idproduct_detail;
With this I am connecting each order with the relative product then selecting item_quantity and price and SUM the product of them.