Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Friday, March 23, 2012

Point label - formatting decimal places

I have calculated a number of fields with the following method:
=SUM(Fields!Asian.Value) / SUM(Fields!Asian.Value + Fields!Alaskan.Value +
Fields!Black.Value + Fields!Hispanic.Value + Fields!Caucasian.Value +
Fields!AmericanIndian.Value + Fields!NotReported.Value) * 100 & "%" & " Asian"
This gives me my Asian population percentage, but when it renders it carries
on so long that I lose my " Asian" off the chart. I just want to limit the
expression to two decimal places. I tried to put the expression to format
the number in the format code as ##.00 as I would a table to limit the
decimal places to two places. What do I need to do to make this happen?
--
Thanks,
ChrisNot sure if you ever got a response.
The formatcode only works if the datatype of your expression is not a
string. In your example however, the expression will generate a string. Try
to use the FormatNumber function inside the calculation and apply the format
code directly:
=FormatNumber( SUM(Fields!Asian.Value) / SUM(Fields!Asian.Value +
Fields!Alaskan.Value + Fields!Black.Value + Fields!Hispanic.Value +
Fields!Caucasian.Value + Fields!AmericanIndian.Value +
Fields!NotReported.Value) * 100, 2) & "%" & " Asian"
See also:
http://msdn.microsoft.com/library/en-us/script56/html/vsfctFormatNumber.asp
Alternatively you could use the Format function which accepts a format code
as argument. E.g.: =Format( ..., "N2")
See also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctformat.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"cmcdavid" <cmcdavid@.discussions.microsoft.com> wrote in message
news:8E76FFB4-15E6-4ED0-841E-B7C722BC193B@.microsoft.com...
> I have calculated a number of fields with the following method:
> =SUM(Fields!Asian.Value) / SUM(Fields!Asian.Value + Fields!Alaskan.Value +
> Fields!Black.Value + Fields!Hispanic.Value + Fields!Caucasian.Value +
> Fields!AmericanIndian.Value + Fields!NotReported.Value) * 100 & "%" & "
Asian"
> This gives me my Asian population percentage, but when it renders it
carries
> on so long that I lose my " Asian" off the chart. I just want to limit
the
> expression to two decimal places. I tried to put the expression to format
> the number in the format code as ##.00 as I would a table to limit the
> decimal places to two places. What do I need to do to make this happen?
> --
> Thanks,
> Chris

Wednesday, March 21, 2012

Plz, what is the most "correct" method

Hi,

Given 2 tables:

Table1:
id Auto,int,PrimKey
table2id int
txt nvarchar50

Table2:
id Auto,int,PrimKey
order int

The scenario: Table2.order defines how the table1.txt is should be ordered.
Table1.table2id contains the id of the order. This cannot be changed :(

How do I select all Table1.txt values but ordered by their corresponding
values of the table2.order field?

--
Thx,
PipHans

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003Hi

The following should do what you require:

SELECT T1.id, T1.txt
FROM Table1 T1 JOIN Table2 T2 ON T1.Table2Id = T2.id
ORDER BY T2.order
John

"PipHans" <piphans@.hotmail.co> wrote in message
news:3f5f47c2$0$48896$edfadb0f@.dtext02.news.tele.d k...
> Hi,
> Given 2 tables:
> Table1:
> id Auto,int,PrimKey
> table2id int
> txt nvarchar50
> Table2:
> id Auto,int,PrimKey
> order int
> The scenario: Table2.order defines how the table1.txt is should be
ordered.
> Table1.table2id contains the id of the order. This cannot be changed :(
> How do I select all Table1.txt values but ordered by their corresponding
> values of the table2.order field?
> --
> Thx,
> PipHans
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003|||John Bell wrote:
> SELECT T1.id, T1.txt
> FROM Table1 T1 JOIN Table2 T2 ON T1.Table2Id = T2.id
> ORDER BY T2.order

It complains about the from-clause being wrong.
If I add "LEFT JOIN" instead of "JOIN", it runs like it should. (thx btw :)

Can you explain why it didnt run with just "join"?

--
Pip

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003|||Hi

A LEFT JOIN would be all rows in the left hand side table (Table1) with any
matching rows in the right hand table (Table2) therefore an entry in Table2
does not have to exist. If an entry in Table2 does not exist then NULL
values are returned.

JOIN (or INNER JOIN) is where both tables have to contain the joined data.

As you didn't post the offending query or the actual error message, the only
thing I can imaging is some other syntax error:

SELECT T1.id, T1.txt
FROM Table1 T1 LEFT JOIN Table2 T2 ON T1.Table2Id = T2.id
ORDER BY T2.order

Should work OK.

John

"PipHans" <piphans@.hotmail.co> wrote in message
news:3f5f7147$0$48899$edfadb0f@.dtext02.news.tele.d k...
> John Bell wrote:
> > SELECT T1.id, T1.txt
> > FROM Table1 T1 JOIN Table2 T2 ON T1.Table2Id = T2.id
> > ORDER BY T2.order
> It complains about the from-clause being wrong.
> If I add "LEFT JOIN" instead of "JOIN", it runs like it should. (thx btw
:)
> Can you explain why it didnt run with just "join"?
> --
> Pip
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003|||PipHans (piphans@.hotmail.co) writes:
> John Bell wrote:
>> SELECT T1.id, T1.txt
>> FROM Table1 T1 JOIN Table2 T2 ON T1.Table2Id = T2.id
>> ORDER BY T2.order
> It complains about the from-clause being wrong.
> If I add "LEFT JOIN" instead of "JOIN", it runs like it should.
> (thx btw :)
> Can you explain why it didnt run with just "join"?

Since what John suggested is legal syntax in SQL Server (save that
he should have put the last "order" in brackets), I suspect that
you are not using SQL Server, but some other DB engine.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog wrote:
> Since what John suggested is legal syntax in SQL Server (save that
> he should have put the last "order" in brackets), I suspect that
> you are not using SQL Server, but some other DB engine.

True, I only tested on Access. - The SQL server cant be reached from home :)

--
/Pip

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003|||John Bell wrote:
> Should work OK.

Yep. It worked on the SQL server at work...I only tested it on access
yesterday.

Thx :)

--
Pip

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 01-09-2003|||PipHans (piphans@.hotmail.co) writes:
> True, I only tested on Access. - The SQL server cant be reached from home

While both Access and SQL Server both claim to run SQL, there are
significant differences between the two - as there is about between
any pair of DBMSs.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

plz help me to upload my sqlserver data base with query analyzer method

plz help me to upload my sqlserver data base with query analyzer method
plz write the code i should write in query analyzer box to uplode
my database(db) in my server(h_server)
and is it neccessary to uplode log file or not
,or guide me with intruducing a sitewhat xactly are you trying to do ? just load up query analyzer to test some queries ? its in the menu under microsoft sql server under your programs menu. or you can open it from tools - > query analyzer from sql server xplorer.

hth|||i understand what you ae saying but i dont know who i replace suitable elements in this code

CREATE DATABASE [co] ON (NAME = N'co_Data', FILENAME = N'e:\sqlserver 2000\MSSQL\data\co_Data.MDF' , SIZE = 1, FILEGROWTH = 10%) LOG ON (NAME = N'co_Log', FILENAME = N'e:\sqlserver 2000\MSSQL\data\co_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
GO

exec sp_dboption N'co', N'autoclose', N'true'
GO

exec sp_dboption N'co', N'bulkcopy', N'false'
GO

exec sp_dboption N'co', N'trunc. log', N'true'
GO

exec sp_dboption N'co', N'torn page detection', N'true'
GO

exec sp_dboption N'co', N'read only', N'false'
GO

exec sp_dboption N'co', N'dbo use', N'false'
GO

exec sp_dboption N'co', N'single', N'false'
GO

exec sp_dboption N'co', N'autoshrink', N'true'
GO

exec sp_dboption N'co', N'ANSI null default', N'false'
GO

exec sp_dboption N'co', N'recursive triggers', N'false'
GO

exec sp_dboption N'co', N'ANSI nulls', N'false'
GO

exec sp_dboption N'co', N'concat null yields null', N'false'
GO

exec sp_dboption N'co', N'cursor close on commit', N'false'
GO

exec sp_dboption N'co', N'default to local cursor', N'false'
GO

exec sp_dboption N'co', N'quoted identifier', N'false'
GO

exec sp_dboption N'co', N'ANSI warnings', N'false'
GO

exec sp_dboption N'co', N'auto create statistics', N'true'
GO

exec sp_dboption N'co', N'auto update statistics', N'true'
GO

use [co]
GO

CREATE TABLE [dbo].[users] (
[u_id] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[u_username] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_password] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_joindate] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_prof] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_fname] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_lname] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_coname] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_location] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_city] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_nation] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_website] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[u_account] [float] NULL
) ON [PRIMARY]
GO