select * from  dbo.tb_Scroe

select Name,(select count(*) from tb_Scroe where Name = t.Name and Scroe = ' - ') as ' - '
,(select count(*) from tb_Scroe where Name = t.Name and Scroe = ' negative ') as ' negative '
 from tb_Scroe as t group by Name;

select a.Name ,a. - ,b. negative from
 (select count(*) - ,Name from tb_Scroe where Scroe=' - ' group by Name ) a
 left join
 (select count(*) negative , Name from tb_Scroe where Scroe=' negative ' group by Name ) b
  on a.Name=b.Name
 
 
  select Name , sum(case when Scroe = ' - ' then 1 else 0 end) ' - ',
  sum(case when Scroe = ' negative ' then 1 else 0 end) ' negative '
  from tb_Scroe group by Name ;
 
 
    select Name ,(case when Scroe = ' - ' then 1 else 0 end) ' - ',
        (case when Scroe = ' negative ' then 1 else 0 end) ' negative '
  from tb_Scroe group by Name ;

Scroe

ID    Name  Scroe     CreateDate

1       Zhang San     -           2014-06-09 00:00:00.000
2      Zhang San     -           2014-06-09 00:00:00.000
3       Zhang San     negative           2014-06-09 00:00:00.000
4       Li Si     negative           2014-06-09 00:00:00.000
5      Wang Wu     negative           2014-06-09 00:00:00.000
6      Li Si     negative           2014-06-09 00:00:00.000
7     Wang Wu      -           2014-06-09 00:00:00.000
9     Zhang San      negative           2014-06-09 00:00:00.000
8     Wang Wu      -           2014-06-09 00:00:00.000
10     Li Si     -           2014-06-09 00:00:00.000

result :

full name    -   negative

Li Si     1   2
Wang Wu     2   1
Zhang San     2   2

sql League tables case then More articles about

  1. sql Interview questions ( Student list _ The curriculum _ League tables _ Teachers list )

    Original link :http://bbs.csdn.net/topics/280002741 Table structure Student(S#,Sname,Sage,Ssex) Student list  Course(C#,Cname,T#) Course ...

  2. Student list The curriculum League tables Teachers list 50 Common use sql sentence

    original text :http://www.cnblogs.com/zengxiangzhan/archive/2009/09/23/1572276.html Student(S#,Sname,Sage,Ssex) ...

  3. Interview questions : database sql Optimize sql Exercises Useful Student list , The curriculum , League tables , Teachers list practice

    What is stored procedure ? What are the advantages and disadvantages ? What is stored procedure ? What are the advantages and disadvantages ? Stored procedures are like functions in our programming language , Encapsulating our code (PLSQL.T-SQL). Advantages of stored procedures : Being able to encapsulate code Saved in the database ...

  4. classic sql Interview questions ( Student list _ The curriculum _ League tables _ Teachers list )

    Reprint :https://www.cnblogs.com/qixuejia/p/3637735.html Table structure Student(S#,Sname,Sage,Ssex) Student list  Course(C#,Cna ...

  5. SQL Frequently asked questions ( Student list _ The curriculum _ League tables _ Teachers list )

    Table structure Student(S#,Sname,Sage,Ssex) Student list  Course(C#,Cname,T#) The curriculum  SC(S#,C#,score) League tables  Teacher(T#,Tname) Teachers' ...

  6. Go to the database foundation of interview : Two 、SQL Advanced case、 Subquery 、 Pagination 、join And view

    One .CASE In two ways 1.1  Equivalent judgment -> amount to switch case (1) Specific usage template : CASE expression WHEN value1 THEN returnvalue1 WHE ...

  7. SQL Medium CASE WHEN usage

    The syntax is as follows : 1)case vlaue when [compare-value]then reslut [when[compare-value]] then result ...] [else res ...

  8. MySQL( Student list 、 Teachers list 、 The curriculum 、 League tables ) Multi-table query

    1. Table structure student(sid,sname,sage,ssex) Student list  course(cid,cname,tid) The curriculum  sC(sid,cid,score) League tables  teacher(tid,t ...

  9. mysql Student's transcript of classic interview questions

    Need database tables 1. Student list Student(SID,Sname,Sage,Ssex) --SID Student number ,Sname The student's name ,Sage date of birth ,Ssex Student gender 2. The curriculum Course(CID, ...

Random recommendation

  1. C Language some commonly used memory allocation function

    First of all, let's look at a problem program ( It's used here TC compiler ): #include "stdlib.h" #include "stdio.h" void main() {    in ...

  2. C In language ‘\n' Why does it mean CRLF Two bytes

    Why do you say this simple question ? as everyone knows , stay Windows The newline character of the next text file is CRLF, Two bytes . stay Unix Next is LF, Take up a byte .( There are also wonderful things Mac yes CR). however C Direct in language printf One ‘\n’, ...

  3. C++ Reference Of “ The trinity ” interpretation

    C++ Is between the assembly language and a high-level language “ The universal ” Language . Its ability is anything else based on VMA( feng - Norman architecture ) The advanced programming language of computer can't match it , And the performance is only C Language can be compared with it . But for a long time , like C++ And hate ...

  4. Deep learning Deep Learning UFLDL newest Tutorial Learning notes 1:Linear Regression

    1 Preface Andrew Ng Of UFLDL stay 2014 year 9 At the end of the month . For starting research Deep Learning It's really great news for children's shoes ! new Tutorial Compared to the old Tutorial Added Conv ...

  5. A brief description RAID Level :

    A brief description RAID Level : RAID 0 It's two disks reading and writing together , If one is broken, all the data will be lost : RAID 1 It's a piece of writing , One for backup , A bad piece doesn't matter : RAID 2 ,3 ,4 Not commonly used : The most common is RAID 5 and R ...

  6. Git Knowledge Overview ( 6、 ... and ) Git Remote operation practice in branch

    The last few blogs talked a lot about Git Content of operation , This blog is still no exception , But the theme of this blog is about git Of remote operation . According to the style of the previous blog , We still rely on LearningGitBranch To explore the related content of ...

  7. Ajax Principle learning

    One .AJAX brief introduction AJAX namely "Asynchronous Javascript And XML"( asynchronous JavaScript and XML), It refers to a web development technology for creating interactive web applications . A ...

  8. Go Installation

    0.  Environmental Science :Ubuntu16.04 64 position 1.  Download installation package , Address :https://golang.org/dl, With 1.8 Version as an example , download go1.8.linux-amd64.tar.gz 2.  decompression ...

  9. kbmMW Load balancing and disaster recovery (2)( Reprint red fish )

    Centralized load balancing In order to realize the centralized load balancing scheme , You need to implement two different application servers , One is an application server that only contains load balancing components and nothing else , It can be called load balancing application server , Hereinafter referred to as" LB Server, The other is to include one or ...

  10. xpath The data and node types of and XPath The basic method of middle node matching

    XPath data type   XPath There are four types of data :  Node set (node-set)  Node set is a set of qualified nodes returned by path matching . Other types of data cannot be converted to node sets .  Boolean value (boolean)  ...