Hello,
I'm trying to something that just works in Oracle, but does not in Sql
Server.
How can I get the percentage of two counts to be returned on each row
of the query?
select count(sid), /* all not the not null */
count(*),
(count(sid) / count(*) ) as percent_not_null,
4 as four,
(3/4) as three_over_four
from dbo.sysusers
70 82 0 4 0
Incredibly, it changes even 3/4 into a zero!
For efficiency, I want the percentage returned in the query.
And to not use variables and coding. Efficiency,
both of the server, and of my time.
Note: I am using dbo.sysusers as an EXAMPLE only. My real
query will be on user defined application tables.
What is the solution please? 4 1824
Integer math
here are 3 ways pick your poison
select 3/4,
(3*1.0)/4,
3.0/4,
convert(decimal(12,3),3)/4
Denis the SQL Menace http://sqlservercode.blogspot.com/
sqlservernew...@yahoo.com wrote:
Hello,
I'm trying to something that just works in Oracle, but does not in Sql
Server.
How can I get the percentage of two counts to be returned on each row
of the query?
select count(sid), /* all not the not null */
count(*),
(count(sid) / count(*) ) as percent_not_null,
4 as four,
(3/4) as three_over_four
from dbo.sysusers
70 82 0 4 0
Incredibly, it changes even 3/4 into a zero!
For efficiency, I want the percentage returned in the query.
And to not use variables and coding. Efficiency,
both of the server, and of my time.
Note: I am using dbo.sysusers as an EXAMPLE only. My real
query will be on user defined application tables.
What is the solution please?
>I'm trying to something that just works in Oracle, but does not in SQL Server. <<
Oracle is the one that does not work and SQL Server is the one that
follows Standards. Wait until you find out how Oracle also screws up
NULLs. If you want decimal placs, then you can CAST() the values to
your needed precision. If you use a number with a decimal point in
it, SQL Server will pick a default precision.
Try
select count(sid), /* all not the not null */
count(*),
(count(sid)*1.0 / count(*) ) as percent_not_null,
4 as four,
(3/4) as three_over_four
from dbo.sysusers
Madhivanan sq*************@yahoo.com wrote:
Hello,
I'm trying to something that just works in Oracle, but does not in Sql
Server.
How can I get the percentage of two counts to be returned on each row
of the query?
select count(sid), /* all not the not null */
count(*),
(count(sid) / count(*) ) as percent_not_null,
4 as four,
(3/4) as three_over_four
from dbo.sysusers
70 82 0 4 0
Incredibly, it changes even 3/4 into a zero!
For efficiency, I want the percentage returned in the query.
And to not use variables and coding. Efficiency,
both of the server, and of my time.
Note: I am using dbo.sysusers as an EXAMPLE only. My real
query will be on user defined application tables.
What is the solution please?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Avinash Dhoot |
last post by:
Hi,
I have a 5 row table with the following values.
key value
1 5
2 10
3 15
4 15
5 5
|
by: michael |
last post by:
I've got a 3-column layout using percentages to define width of each
div-column.
#left-col { width: 20%; background-color: green; float:left; }
#center-col { width: 60%; background-color: blue;...
|
by: Megan |
last post by:
quick summary: i'm having problems trying to group fields in a report
in order to calculate percentages. to calculate percentages, i'm
comparing the results from my grouped fields to the totals....
|
by: Mike Barnard |
last post by:
Hi all.
I am playing with html and css. I don't (yet) have a working site,
I'm just trying to build a working, basic template I can use for a
couple of ideas I have.
I recall reading a...
|
by: Chris H |
last post by:
I am wanting to write a function for a poker league manager that will
detrmine players finishing points in a tournament depending on the amount of
players that played... In other words when the...
|
by: Bob Alston |
last post by:
I need to produce a report like this
Color: # %
------ --- ---
White 10 20
Black 25 50
other 15 30
---- ----
Total 50 100
|
by: eliana82 |
last post by:
I have problems calculating score percentages within groups.
I have created a boat program in access where the information provided is name, team, boat and score.
The first query I've done is...
|
by: martin DH |
last post by:
Access 2003
I have a table (TASKS) filled with data from an external source. The table lists several tasks for employees to complete and has a text field (STATUS) that identifies where in the...
|
by: buddyr |
last post by:
Hello,
can I write a query that will give percentages of records in one field?
table example:
table1
IdNumber model condition
01 045 good
01 045 ...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |