Answer to Question #284141 in Databases | SQL | Oracle | MS Access for Lovely

Question #284141

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.


1
Expert's answer
2022-01-05T01:40:09-0500
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