Let us say that I have a table structured like this(using SQL server):
empID INT
payment INT
Now, each employee only gets paid either 50.00 or 100.00. There are two employees earning 50.00 and three earning 100.00.
How would I do a select statement so that the result set was like this:
50.00 100
----- -----
2 3
Where 50.00 and 100.00 are the column headers, and the number below are the actual values. I know that I can do
SELECT payment, COUNT(*)
FROM Student
GROUP BY payment
But that returns the payment in its own column. I want each different payment value in its own column.
Here’s how:
But, with floating point numbers, you should never do equal comparisons. It is better to do something like:
or something like that.