[Show all top banners]

chinday
Replies to this thread:

More by chinday
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 SQL query Help!
[VIEWED 1395 TIMES]
SAVE! for ease of future access.
Posted on 02-12-19 6:41 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

Can you please help me get sql query for below output from the input provided :

TABLE:

No of classes Student
Science A
Commerce A
Science B
Science C
Commerce C
Commerce C
Science B
Science A
Science G
Commerce D
Commerce D
OUTPUT:

No of classes Student Count
Science A 2
Commerce A 1
Science B 2
Science C 1
Commerce C 2
Commerce D 2
Science G 1

I will appreciate the help.


 
Posted on 02-12-19 6:50 PM     [Snapshot: 13]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

You might want to try something like this:

select number of classes, student, count(*) as Count
From tablename
group by number of classes, student

Good luck!
 
Posted on 02-12-19 9:54 PM     [Snapshot: 119]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

SELECT NO OF CLASSES,STUDENT,COUNT(*) AS COUNT
FROM TABLE
GROUP BY NO OF CLASSES,STUDENT
ORDER BY STUDENT ASC;
 
Posted on 02-13-19 1:42 AM     [Snapshot: 157]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

SELECT [No of classes], Student, COUNT(*) AS Count
FROM TABLE
GROUP BY [No of classes], Student
ORDER BY Student ASC, [No of classes] DESC;
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 30 days
Recommended Popular Threads Controvertial Threads
TRUMP 2016!!! Here is why?
Anyone renewed their passport through DC embassy lately?
नेपाली समुदायको भारी समर्थन Iowa caucus मा Bernie Sanders लाई - PHOTOS
कोमल ओलि र धिरेन्द्र बिचको अफेयर
अमेरिकामा नेपालीलाई दुःख छ, सकभर नजानुस
पुन्टर पिन्कु र नाज ब्रो
is it good to marry girl who are already in US or go back to Nepal and do arrange marriage?
Pete Buttigieg is the new Hillary Clinton
अब नसुध्रि शुख - आस्था राउतले डण्ठे भन्दै गालि नगरेको भए कसैले सुन्थेन ....
US upcoming recession --- is it good time to buy house when rates are low or is it good time to wait recession?
पिउनको सम्पत्ति ९ करोड ७३ लाख
Question on getting advance parole for tps holder.
Democrat’s presidential nominee should have Mitt Romney as VP
American Idol मा पहिलोपटक नेपाली केटाेकाे यस्तो दम्दार प्रस्तुति | Dibesh Pokharel | Arthur Gunn
थुतुनो र मुतुनो ठिक ठाउँमा भएन भने life damage !!!
W2 issue
TPS TO GC TO AOS INTERVIEW
travel from nepal to US amid corona virus
Nepalese Man Sentenced on Marriage Fraud Charges
In big Dilemma , help plz
TRUMP 2016!!! Here is why?
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters