Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT STUDENTID, COURSEID, COURSENAME, COURSEGROUP
FROM SOME_VIEW
WHERE STUDENTID=:STU_ID
--GROUP BY STUDENTID, COURSEID, COURSENAME
ORDER BY STUDENTID


I want the previous code to work like the following
if we have 2 data Rows

STUDENTID COURSEID COURSENAME COURSEGROUP
15 PHY144
Posted
Comments
Bernhard Hiller 20-Mar-12 9:23am    
What do you want?:
- The parameter :STU_ID may contain more than one ID value
- Get column names included in the output
- something else?
kareem salem 21-Mar-12 4:34am    
sorry this is incomplete question I think It submitted while writing
It's Compelled here
http://www.codeproject.com/Questions/350775/How-group-by-works

Your question is not exactly clear. I think what you need to do is,

SQL
SELECT DISTINCT STUDENTID, COURSEID, COURSENAME, COURSEGROUP
FROM   SOME_VIEW
WHERE  STUDENTID = :STID
 
Share this answer
 
hi,
try this,

SELECT STUDENTID, COURSEID, COURSENAME, COURSEGROUP
FROM SOME_VIEW
GROUP BY STUDENTID, COURSEID, COURSENAME
HAVING STUDENTID=STU_ID
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900