SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Help in grouping


SQL Help in grouping

Author
Message
gksharmaajmer
gksharmaajmer
SSC-Enthusiastic
SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)SSC-Enthusiastic (180 reputation)

Group: General Forum Members
Points: 180 Visits: 112
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
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41865 Visits: 20008
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
Sergiy
Sergiy
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25814 Visits: 12469
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search