473,625 Members | 3,318 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with counting rows

1 New Member
Here is a sample database for my problem:

Table t:

Expand|Select|Wrap|Line Numbers
  1. Num Winner Loser
  2. 0 Fred Harry
  3. 1 Harry George
  4. 2 Fred Eric
  5.  
I can get a counted ordered list of winners

SELECT DISTINCT Winner, COUNT(*) AS theCount FROM t GROUP BY Winner ORDER BY theCount DESC

Giving

Fred, 2
Harry 1
George 0
Eric 0

Same applies for losers also.

But I actually also want to total up Winner or Loser so that my result should be

Fred 2
Harry 2 (1 for winner, 1 for loser)
George 1
Eric 1

so this is really the sum of number of wins + number of losses

I have tried allsorts - could someone please point me in the right direction?

Thanks in advance
Jan 21 '08 #1
0 843

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3835
by: Reply via newsgroup | last post by:
Folks, When performing an update in mysql (using PHP), can I find out how many records were matched? mysql_affected_rows() won't work... and I have the following problem that I thought I could resolve with a simple function: Example: I have 50records - I want to update a selection of the recods - some,
0
1437
by: DavidC | last post by:
Anyone know how to count rows in a table depending on 2 columns, and different values within the second column. Basically i am trying to obtain the resultset example below from the table example below TABLE example: Date | Status -------------------------
16
1715
by: walexand | last post by:
I use the database mysql v.4. My problem is... I have a select like: select * from user where language = "de"; the result are then: id name =================== 1 max
2
1630
by: Trent | last post by:
Hello. I am trying to execute a statement that works fine in ms sql but will not work in mysql. There are three tables. user (user_sid, user_name, user_email), file (file_sid, file_name, file_desc), file_access (file_sid, user_sid). Here is what I want: Given a particular file_sid return all users with an extra column (1,0) inticated whether or not there was a match in the file_access
3
3039
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks. - Vish
4
1240
by: Bryan Martin | last post by:
Given the following table setup Table column1 column2 forumCategory ID name
2
1748
by: Adam | last post by:
In my MYISAM table I have an index (Index_A) on 2 fields (Field_A, Field_B). There are millions of rows in the table. The cardinality of Index_A is 53. I think a query to count the number of rows that match a pair of values for Field_A and Field_B should execute blindingly fast (in the index count the number of leaf nodes for the B-Tree node representing the indexed pair of values). My query looks like: SELECT count(*) FROM `table_A`...
1
3047
by: Newmanbt | last post by:
I've got the following code testlabel.Text = allquestions.Select().Count.ToString(); GridView1.DataSource = allquestions.Select(); GridView1.DataBind(); testlabel.Text = GridView1.Rows.Count.ToString(); allquestions.Select().Count.ToString(); is reporting the correct value, but GridView1.Rows.Count.ToString(); is reporting the incorrect value (it is reporting 0)
3
6027
sharijl
by: sharijl | last post by:
I see tutorials all over the web with pagination and MySQl but not much out there (that is updated using PHP 5 without global variables) on doing this using ODBC connection with MSSQL. This is what I found online but I am confused. <?php //connecting to the database using ODBC $db=odbc_connect($dsn,$user,$pass)or die("Error: Can't Connect to Database"); // assigns a value how many rows we will get from each page
2
5306
by: LilMeechc20 | last post by:
Hello, I have a group assignment that I have to do. We have to write a Tic Tac Toe game. One person in my group has managed to write the code for a multiplayer (human -vs- human) game and I managed to write a code for a single player (human -vs- computer) game. My problem is, now we want to merge the two games with options to pick which game you would like to play. However, the games were written totally different styles and I can't...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.