Answer to Question #193416 in Databases | SQL | Oracle | MS Access for p.kusal phanindra

Question #193416

1.

Get the top 10 channels for which more number of users are subscribed in the year 2018.

Note:

In case, if the no_of_subscribers are same, then sort the output in the ascending order of channel_name.

Expected Output Format:

channel_id channel_name no_of_subscribers


1
Expert's answer
2021-05-14T23:07:12-0400
from django.db import models
	from datetime import datetime
	

	from users.models import User
	

	# Create your models here.
	

	

	class Channel(models.Model):
	    channel_name = models.CharField(max_length=100, unique=True)
	    user_id = models.ForeignKey(User, null=False,  on_delete=models.CASCADE)
	    bio = models.TextField(max_length=500, blank=False)
	    date_created = models.DateTimeField(default=datetime.now())
	    no_of_subscribers = models.IntegerField(default=0)
	

	

	class ChannelSubscriberTracker(models.Model):
	    channel_id = models.ForeignKey(
	        Channel, null=False, on_delete=models.CASCADE)
	    user_id = models.ForeignKey(User, null=False, on_delete=models.CASCADE)
	    date_subscribed = models.DateTimeField(default=datetime.now())
	

	    class Meta:
	        verbose_name_plural = "ChannelSubscriberTrackers"

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS