Issue
How to display the information of the customer who has the most 'use' in 'audit' table.
problem i dont know how to get information customer.
select * from audit where used=
(select MAX(used) from audit)
audit table
customer table
Solution
Sort your subquery highest to lowest and then take the first row with LIMIT 1
.
Select *
FROM customer_table
WHERE customer_ID = (
SELECT customer_ID
FROM audit_table
ORDER BY USED DESC
LIMIT 1
)
You may want to consider what happens if two customers have the same value in USED
. It looks like there is a tie between C001
& C002
but this query will only return one customer
Answered By - urdearboy
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.