"virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."
Sonia M. - "virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."See full answer
"Schema is wrong - id from product is mapped to id from transactions, id from product should point to product_id in transcations table"
Arshad P. - "Schema is wrong - id from product is mapped to id from transactions, id from product should point to product_id in transcations table"See full answer
Data Analyst
Coding
+1 more
🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.
"This problem can be solved with two approaches
Iterative approach
Recursive approach
Quite easy to think about the iterative approach, you can make use of a while loop in that case. But what if you want to make use of previously computed values? That case going for the recursive solution is quite useful.
class Collatz:
def init(self) -> None:
self.cache = {}
self.steps = 0
def steps_from(self, n) -> int:
# base case
if n == 1:
"
Frederick A. - "This problem can be solved with two approaches
Iterative approach
Recursive approach
Quite easy to think about the iterative approach, you can make use of a while loop in that case. But what if you want to make use of previously computed values? That case going for the recursive solution is quite useful.
class Collatz:
def init(self) -> None:
self.cache = {}
self.steps = 0
def steps_from(self, n) -> int:
# base case
if n == 1:
"See full answer
"WITH cte AS (
SELECT customer_id,
COUNT(*) AS noofoffences
FROM transactions
WHERE receipt_number like '%999%'
OR receipt_number like '%1234%'
OR receipt_number like '%XYZ%'
GROUP BY 1
HAVING COUNT(*) >=2
)
SELECT firstname, lastname,
receipt_number,
noofoffences
FROM cte
INNER JOIN customers
using(customer_id)
INNER JOIN transactions
using(customer_id)
ORDER BY 1,2,3,4
`"
Michelle M. - "WITH cte AS (
SELECT customer_id,
COUNT(*) AS noofoffences
FROM transactions
WHERE receipt_number like '%999%'
OR receipt_number like '%1234%'
OR receipt_number like '%XYZ%'
GROUP BY 1
HAVING COUNT(*) >=2
)
SELECT firstname, lastname,
receipt_number,
noofoffences
FROM cte
INNER JOIN customers
using(customer_id)
INNER JOIN transactions
using(customer_id)
ORDER BY 1,2,3,4
`"See full answer
"Example:
bucket A: 3 liters capacity
bucket B: 5 liters capacity
goal: 4 liters
You are asked to print the logical sequence to get to the 4 liters of water in one bucket.
Follow up:
How would you solve the problem if you have more than 2 buckets of water?"
B. T. - "Example:
bucket A: 3 liters capacity
bucket B: 5 liters capacity
goal: 4 liters
You are asked to print the logical sequence to get to the 4 liters of water in one bucket.
Follow up:
How would you solve the problem if you have more than 2 buckets of water?"See full answer
"-- Write your query here
select d.departmentname, sum(o.orderamount) as total_revenue
from departments d
join orders o on d.departmentid = o.departmentid
where o.order_date >= date('now', '-12 months')
group by 1
order by 2 desc;
`"
Anonymous Roadrunner - "-- Write your query here
select d.departmentname, sum(o.orderamount) as total_revenue
from departments d
join orders o on d.departmentid = o.departmentid
where o.order_date >= date('now', '-12 months')
group by 1
order by 2 desc;
`"See full answer
"SELECT upsellcampaignid, COUNT(DISTINCT trans.userid) AS eligibleusers
FROM campaign
JOIN "transaction" AS trans
ON transactiondate BETWEEN datestart AND date_end
JOIN user
ON trans.userid = user.userid
WHERE iseligibleforupsellcampaign = 1
GROUP BY upsellcampaignid
`"
Alina G. - "SELECT upsellcampaignid, COUNT(DISTINCT trans.userid) AS eligibleusers
FROM campaign
JOIN "transaction" AS trans
ON transactiondate BETWEEN datestart AND date_end
JOIN user
ON trans.userid = user.userid
WHERE iseligibleforupsellcampaign = 1
GROUP BY upsellcampaignid
`"See full answer
"select DISTINCT p.product_id,
p.product_name ,
CASE when sale_date is null then 'Not Sold'
else 'Sold'
END as sale_status
from products p
left join sales s
on p.productid= s.productid
`"
Gowtami K. - "select DISTINCT p.product_id,
p.product_name ,
CASE when sale_date is null then 'Not Sold'
else 'Sold'
END as sale_status
from products p
left join sales s
on p.productid= s.productid
`"See full answer
"SELECT DISTINCT title,
ROUND(AVG(rating) over (partition by title),1) avg_rating,
ROUND(AVG(rating) over (partition by genre),1) genre_rating
FROM rating r
JOIN movie m
ON r.movieid=m.movieid
ORDER by 1"
Harshi B. - "SELECT DISTINCT title,
ROUND(AVG(rating) over (partition by title),1) avg_rating,
ROUND(AVG(rating) over (partition by genre),1) genre_rating
FROM rating r
JOIN movie m
ON r.movieid=m.movieid
ORDER by 1"See full answer