Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

SQL Help in grouping Expand / Collapse
Author
Message
Posted Wednesday, October 2, 2013 10:27 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, January 1, 2014 2:28 AM
Points: 47, Visits: 110
Thank you Chris for your continue support. Probably I am not able to find a bug in the query but when I am saying :

SELECT *
FROM #Results
WHERE student_name <> 'Default'

which is not returning me the required output No. 3, same when I am saying :

SELECT *
FROM #Results
WHERE student_name = 'Default'

is not returning me the required output No. 2, while

SELECT *
FROM #Results

is giving me the correct oupput of required output No. 1.

I am really thankful to you for your valuable code which is simultaneously giving me the learning of SQL too (in which I am very much poor)


Regards
Girish Sharma
Post #1500843
Posted Thursday, October 3, 2013 12:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, September 12, 2014 9:43 AM
Points: 7,284, Visits: 13,824
gksharmaajmer (10/2/2013)
Thank you Chris for your continue support. Probably I am not able to find a bug in the query but when I am saying :

SELECT *
FROM #Results
WHERE student_name <> 'Default'

which is not returning me the required output No. 3, same when I am saying :

SELECT *
FROM #Results
WHERE student_name = 'Default'

is not returning me the required output No. 2, while

SELECT *
FROM #Results

is giving me the correct oupput of required output No. 1.

I am really thankful to you for your valuable code which is simultaneously giving me the learning of SQL too (in which I am very much poor)


Regards
Girish Sharma


You're welcome.

Apart from the first row of your third table (which I don't think should be there), the queries appear to generate the correct results from your sample data. If you are getting different results then describe what you see - check using the sample data set you've provided which may differ from your actual data. If this is the case, then set up a new sample data set which demonstrates.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1501013
Posted Monday, October 14, 2013 10:41 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 7:10 PM
Points: 4,576, Visits: 8,349
gksharmaajmer (10/2/2013)
Thank you Chris for your continue support. Probably I am not able to find a bug in the query but when I am saying :

SELECT *
FROM #Results
WHERE student_name <> 'Default'

which is not returning me the required output No. 3, same when I am saying :

SELECT *
FROM #Results
WHERE student_name = 'Default'

is not returning me the required output No. 2, while

SELECT *
FROM #Results

is giving me the correct oupput of required output No. 1.

I am really thankful to you for your valuable code which is simultaneously giving me the learning of SQL too (in which I am very much poor)


Regards
Girish Sharma


You need to translate your requests to data language:

"List of Courses in which student got Default marks:" - in fact means "List of courses with a single entry in the final dataset" (table #Result);
and
"List of Courses in which student got Non-Default marks:" - means "List of courses with more than 1 entry in the final dataset".

Should be easy task from here.
Post #1504600
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse