Tuesday, February 28, 2006

Microsoft SQL Server - Using Derived Tables to Calculate Aggregate Values - SQLTeam.com:

Garth on 11/18/2001 in SELECT
Calculating aggregate values can be simplified by using derived tables. In this article I show you how to use derived tables to calculate two independent aggregate values in a single SELECT statement.

Derived Table Basics

A derived table is one that is created on-the-fly using the SELECT statement, and referenced just like a regular table or view. Derived tables exist in memory and can only be referenced by the outer SELECT in which they are created. A simple use of a derived table is shown here.

SELECT *
FROM (SELECT *
FROM Sales) AS a

The inner SELECT produces a derived table and replaces a regular table or view. The key thing to remember when using derived tables is that you must always use an alias (e.g., AS a). The following shows the error produced when the alias is omitted.

SELECT *
FROM (SELECT *
FROM Sales)

-- Results --

Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near ')'.

Referencing Multiple Derived Tables

You can add as many derived tables as needed to a single outer SELECT to produce the desired resultset. The code starts to get a little convoluted after the second inner SELECT is added, but if you focus on the columns returned by each SELECT it all makes sense.

The following script creates Stores/Sales information and shows how to calculate current month and year-to-date sales count and amounts by Store.

USE tempdb
go
SET NOCOUNT ON

CREATE TABLE Stores
(
Sto_ID smallint IDENTITY PRIMARY KEY NOT NULL,
Sto_Name varchar(20) NOT NULL
)
go
INSERT Stores VALUES ('Store 1')
INSERT Stores VALUES ('Store 2')
INSERT Stores VALUES ('Store 3')
go

CREATE TABLE Sales
(
Sal_ID int IDENTITY NOT NULL PRIMARY KEY,
Sto_ID smallint NOT NULL FOREIGN KEY REFERENCES Stores(Sto_ID),
Sal_Date smalldatetime NOT NULL,
Sal_Amt money NOT NULL
)
go
INSERT Sales VALUES (1,'5/15/01 14:00:00',500)
INSERT Sales VALUES (1,'5/16/01 11:00:00',200)
INSERT Sales VALUES (1,'6/15/01 14:00:00',200)
INSERT Sales VALUES (1,'7/15/01 08:00:00',500)
INSERT Sales VALUES (1,'8/16/01 10:00:00',100)
INSERT Sales VALUES (1,'8/17/01 10:00:00',125)

INSERT Sales VALUES (2,'5/1/01 08:00:00',100)
INSERT Sales VALUES (2,'6/16/01 14:00:00',200)
INSERT Sales VALUES (2,'7/16/01 09:00:00',500)
INSERT Sales VALUES (2,'8/17/01 10:00:00',100)

INSERT Sales VALUES (3,'5/25/01 15:00:00',250)
INSERT Sales VALUES (3,'6/17/01 14:00:00',100)
INSERT Sales VALUES (3,'7/16/01 09:00:00',600)
INSERT Sales VALUES (3,'8/18/01 16:00:00',150)
go

DECLARE @RunDate datetime
Set @RunDate = '9/01/01'

SELECT a1.Sto_Name,
CM_Count,
CM_Sales,
YTD_Count,
YTD_Sales
FROM (SELECT b.Sto_Name,
COUNT(*) AS CM_Count,
SUM(Sal_Amt) AS CM_Sales
FROM Sales a
JOIN Stores b ON a.Sto_ID = b.Sto_ID
WHERE DATEPART(yy,Sal_Date) = DATEPART(yy,@RunDate) AND
DATEPART(mm,Sal_Date) = (DATEPART(mm,@RunDate)-1)
GROUP BY b.Sto_Name) AS a1
JOIN (SELECT Sto_Name,
COUNT(*) AS YTD_Count,
SUM(Sal_Amt) AS YTD_Sales
FROM Sales a
JOIN Stores b ON a.Sto_ID = b.Sto_ID
WHERE DATEPART(yy,Sal_Date) = DATEPART(yy,@RunDate)
GROUP BY b.Sto_Name) AS b1 ON a1.Sto_Name = b1.Sto_Name
GO

-- Results --

Sto_Name CM_Count CM_Sales YTD_Count YTD_Sales
-------------------- ----------- --------------------- ----------- -------------
Store 1 2 225.0000 6 1625.0000
Store 2 1 100.0000 4 900.0000
Store 3 1 150.0000 4 1100.0000

The first inner SELECT calculates August's sales by comparing the month and year of @RunDate to the month and year of Sal_Date. Notice that I subtracted one month from @RunDate, because the assumption is the code is executed after the previous month has closed. You should also notice that the outer SELECT uses "a1." to specify which Sto_Name is returned. The column needs to be qualified because it exists in both the a1 and b1 derived tables.

The second inner SELECT calculates year-to-date totals by comparing the year of @RunDate to the year of Sal_Date. Once this table has been derived it can be joined to a1 on Sto_Name so the two independent aggregate values can be combined in the same resultset.

Monday, February 27, 2006

synch distibutor to recruit tree order, stack-based traversing


SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO




alter PROCEDURE SynchRecruitTreeStartFromDistRootAll

AS




truncate table recruit

DECLARE @Counter INT



declare @RootSponsorToDrill VARCHAR(10)

select @RootSponsorToDrill = (SELECT DistNo FROM Dist WHERE rtrim(Sponsor) = '')


SET @Counter = 1
INSERT INTO Recruit(DistNo, Sponsor, TreeLevel, TreeOrder, HiOrder)
SELECT DistNo, Sponsor, 1, @Counter, 0 FROM Dist WHERE rtrim(Sponsor) = ''


DECLARE @SponsorToDrill VARCHAR(10)
SET @SponsorToDrill = @RootSponsorToDrill





SET NOCOUNT ON

DECLARE @StackDist TABLE
(
StackDepth INT,
Ndx INT,
DistNo VARCHAR(10),
Sponsor VARCHAR(10),
ImmediateDownlineCount INT,
TreeOrder INT,
HiOrder INT
)

DECLARE @StackCounter TABLE
(
ParentSponsor VARCHAR(10),
StackDepth INT,
I INT,
N INT
)




DECLARE @StackDepth INT
SET @StackDepth = 1
INSERT INTO @StackCounter(StackDepth, I, N, ParentSponsor) SELECT @StackDepth, 0, 0, @SponsorToDrill


goDrill:

--- push all dist of sponsor, stackdepth..


DECLARE @N INT

SET @N = 0
DECLARE @c CURSOR
SET @C = CURSOR FOR
SELECT DistNo, Sponsor FROM Dist WHERE Sponsor = @SponsorToDrill
OPEN @C

DECLARE @DistNo VARCHAR(10)
DECLARE @Sponsor VARCHAR(10)
DECLARE @ImmediateDownlineCount INT

FETCH NEXT FROM @C INTO @DistNo, @Sponsor
WHILE @@FETCH_STATUS = 0 BEGIN
INSERT INTO @StackDist(StackDepth, Ndx, DistNo, Sponsor)
SELECT @StackDepth, @N, @DistNo, @Sponsor
SET @N = @N + 1
FETCH NEXT FROM @C INTO @DistNo, @Sponsor
END
CLOSE @C
DEALLOCATE @C
-- ..push all dist of sponsor, stackdepth

DECLARE @I INT

SET @I = 0
goProcess:
WHILE @I < @N BEGIN

/* declare @s varchar(800) select @s = REPLICATE('-',@StackDepth * 2) + DistNo FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I -- print @s -- INSERT INTO @X(S) SELECT @S */


SET @Counter = @Counter + 1

INSERT INTO Recruit(DistNo, Sponsor, TreeOrder, TreeLevel)
SELECT DistNo, Sponsor, @Counter, @StackDepth + 1
FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I

/*UPDATE @StackDist SET TreeOrder = @Counter WHERE DistNo = (SELECT DistNo FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I)*/


IF EXISTS( SELECT * FROM Dist WHERE Sponsor =
(SELECT Distno FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I))
BEGIN
-- push i, n, stackdepth..
SELECT @SponsorToDrill = DistNo FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I


SET @StackDepth = @StackDepth + 1

INSERT INTO @StackCounter(StackDepth, I, N, ParentSponsor)
SELECT @StackDepth, @I, @N, @SponsorToDrill
GOTO goDrill -- ..push i, n, stackdepth

END

SET @I = @I + 1

END


-----------------------------



IF @SponsorToDrill = '00000000' BEGIN
SELECT 'MICHAEL ' + CONVERT(VARCHAR, @Counter)
END

-- pop I, N..

SELECT @I = I + 1, @N = N, @SponsorToDrill = ParentSponsor
FROM @StackCounter WHERE StackDepth = @StackDepth

-- ..pop I, N

UPDATE Recruit SET HiOrder = @Counter
WHERE DistNo = @SponsorToDrill

DELETE FROM @StackDist
WHERE StackDepth = @StackDepth

DELETE FROM @StackCounter
WHERE StackDepth = @StackDepth

SET @StackDepth = @StackDepth - 1

IF @StackDepth > 0 BEGIN
GOTO goProcess
END


SET NOCOUNT OFF




--SELECT * FROM @Drills order by sponsor

PRINT 'Finished synching'


Sunday, February 26, 2006

INF: Shrinking the Transaction Log in SQL Server 2000 with DBCC SHRINKFILE: "MORE INFORMATION
When DBCC SHRINKFILE is run, SQL Server 2000 shrinks the log file by removing as many virtual log files as it can to attempt to reach the target size. If the target file size is not reached, SQL Server places dummy log entries in the last virtual log file until the virtual log is filled and moves the head of the log to the beginning of the file. The following actions are then required to complete the shrinking of the transaction log:
1. You must run a BACKUP LOG statement to free up space by removing the inactive portion of the log.
2. You must run DBCC SHRINKFILE again with the desired target size until the log file shrinks to the target size.
The following example demonstrates this with the pubs database and attempts to shrink the pubs_log file to 2 MB:
1. Run this code:

DBCC SHRINKFILE(pubs_log, 2)


NOTE: If the target size is not reached, proceed to the next step.
2. Run this code if you want to truncate the transaction log and not keep a backup of the transaction log. Truncate_only invalidates your transaction log backup sequence. Take a full backup of your database after you perform backup log with truncate_only:

BACKUP LOG pubs WITH TRUNCATE_ONLY

-or-
Run this code if you want to keep a backup of your transaction Publish Post log and keep your"

ONDotnet.com -- Rapid Application Development with VB.NET 2.0: "For a couple of years now, I've been touting the Microsoft-endorsed sentiment that it really doesn't matter if you program in C# or in VB.NET, since both are just syntactic sugar layered on top of MSIL (Microsoft Intermediate Language, the true language of .NET). That appears to be changing a bit with Whidbey.

Microsoft seems to be targeting Visual Basic 2.0 a bit more towards Rapid Application Development (RAD), and thus the designers of VB2 have added a few features to make developing applications quicker and easier. A key feature in this approach is the My object. The My object exposes six top-level objects for fast access to various aspects of your application, environment and resources. These are:

* My.Application
* My.Computer
* My.User
* My.Webservices
* My.DataSources"

Saturday, February 25, 2006

Google Groups : Remedy ARS: "One method I have used many times without any problems is to Detach the
database, delete or rename the transaction log, and then Attach the
database. A new empty transaction log will be created.

SQL Server 2000. "

Slashdot | Statically Charged Man Ignites Office: "If it's a hoax, it's fooled a lot of people.

And sadly, that's quite easy. All you have to do to fool the news media is fool one semi-reputable source (in this case Reuters). Soon enough all the other newspapers will pick it up like you're living in an echo chamber."

Ghost and spirit pictures, reported to be real.: "Fake

Keep in mind that all 'ghostly' pictures are not what they appear to be. We took the above picture on 18 Jan 04. We watched as the flash misfired in a darkened room. That's what made this. Made with a Canon digital camera and sharpened with Paint Shop Pro software."

BBC News | SCI/TECH | Q&A: Therapeutic human cloning:

Q&A: Therapeutic human cloning
Stem BBC
Cloning could produce perfect-match tissue
The law on human cloning in the UK is to be relaxed to allow scientists to take cells from early-stage embryos and use them to grow skin and other tissue.

Final approval of so-called therapeutic cloning will have to pass a free vote in Parliament first, but ministers believe this very promising, but highly controversial, technology should be pursued.

BBC News Online's science editor Dr David Whitehouse answers questions on the subject.

Q. What is therapeutic cloning?

A. Scientists would like to create human embryos in the lab and mine them for special cells that can be used in revolutionary medical treatments. One often hears the term embryo cloning in relation to this work, but this is a misuse of the term and gives a wrong impression of what actually takes place. Scientists are not copying embryos. What they do is take the genetic material from a cell in an adult's body and fuse it with an empty egg cell. With the right trigger, this new cell can then be persuaded to develop into an embryo. It is the same basic technology that gave us Dolly the sheep.

Q. Why do researchers want to do it?

A. To extract so-called embryonic stem cells. These are the master cells that have the potential to develop into any other type of cell in the body. For example, they could develop into nerve tissue, blood, heart muscle and even brain cells. Scientists have been trying to isolate and culture these special cells in the lab for many years. When they finally achieved it in 1998, it was hailed as one of the great breakthroughs in modern research.

Researchers believe stem cells can provide us with a ready supply of replacement tissue. Initially, individual cells would be implanted into our bodies to repair the damage caused by degenerative illnesses like heart disease. Ultimately, however, it may be possible to persuade stem cells to grow into complete organs. But if this is possible, it is many years away.

Q. Why is cloning such an important part of this?

A. It is important because it would allow the creation of perfect-match tissue. At the moment, if you have a transplant your body will try to reject the donated cells because it sees them as foreign. Doctors dampen this immune response by prescribing powerful anti-rejection drugs that patients must take for life. But the cells created through therapeutic cloning would not have this problem. They would be derived from the patient him/herself and the immune system would recognise the cells as the body's own.

This approach could end, for example, a leukaemia patient's desperate search for the right bone marrow donor. With therapeutic cloning, doctors would create perfectly matched bone marrow using perhaps the patient's own skin cells.

Q. What other diseases could be tackled this way?

A. Certainly any degenerative disease where one cell type has gone wrong. Scientists are very confident new nerve cells can be transplanted into sufferers of Parkinson's and Alzheimer's disease. New heart muscle could repair damaged hearts.

Q. Can stem cells be obtained any other way?

A. Embryonic stem cells can only be obtained from embryos, but it is possible to get so-called adult stem cells from adults. It is not clear whether these have the complete flexibility of the embryonic cells. Although research has shown for example that adult bone marrow cells can become liver cells, we may need embryonic stem cells to get the full range of body cell types.

Q. What do the opponents say?

A. The breakthrough research on embryonic stem cells was done on aborted foetuses and unwanted embryos from IVF treatment. Some groups argue that a human embryo, even the very small clump of cells being talked about here, is a human life and as such is sacrosanct. They see it as outrageous that scientists should be allowed to create something which has life merely to discard it after they have "harvested" some important cells.

Q. Is there a solution here?

A. Possibly. With more research, we may find that adult stem cells are just as useful and flexible and this would negate the need for embryos. Also, the scientists who created Dolly the sheep and the researchers who first isolated the embryonic stem cells are combing their knowledge. They think it might be possible to "reprogram" an adult cell - even one as specialised as a skin cell, for example - to become any other cell type in the body. This sort of technology is far from being realised and would also require, in the short term, work on embryos to learn some of the secrets of how early cells are controlled.

DNA - Wikipedia, the free encyclopedia: "Watson, Crick, and Wilkins were awarded the 1962 Nobel Prize for Physiology or Medicine for discovering the molecular structure of DNA, by which time Franklin had died from cancer, at the age of 37. Nobel prizes are not awarded posthumously; had she lived, the difficult decision over whom to jointly award the prize would have been complicated as the prize can only be shared between two or three. "

Pheromones and Mammals: "Humans are 'the hardest of all' mammals to work with, Singer says. Yet some studies suggest that humans may also respond to some chemical signals from other people. In 1971, Martha McClintock, a researcher who is now at the University of Chicago (she was then at Harvard University), noted that college women who lived in the same dormitory and spent a lot of time together gradually developed closer menstrual cycles. Though the women's cycles were randomly scattered when they arrived, after a while their timing became more synchronized."

Thursday, February 23, 2006

BUSINESS 2.0: The 70 percent solution - Nov. 28, 2005: "'What you cannot avoid, welcome' is an old Chinese proverb"

Signs on the Sand: { First 10 digit prime in consecutive digits of e }.com: "I agree. The first part seems to be easily solved by a brute force algorithm. The second part is a different sort. As long as you can recognize the pattern and make an intuitive leap, it is a simple program to write to do what you need to do.

I think Google wanted to make it easy for the type of engineers they are looking for and hard for those that can't not think in non-linear fashions.

I like the fact that the used e as pretty much just an intimidation factor - or maybe a geek coolness factor."

stack-based traversing

/* this is my stack-based approach to traversing, sql server has limit on nesting depth of stored proc to 32, it's not viable to use recursive algo */


alter PROCEDURE DrillDownlinesTree
@RootSponsorToDrill VARCHAR(10)

AS

DECLARE @SponsorToDrill VARCHAR(10)
SET @SponsorToDrill = @RootSponsorToDrill

DECLARE @Drills TABLE
(
DistNo VARCHAR(10),
Sponsor VARCHAR(10),
TreeLevel INT,
DownlineCount INT,
ImmediateDownlineCount INT,
RecruitProximity INT
)


INSERT INTO @Drills(
DistNo,
Sponsor,
TreeLevel,
DownlineCount,
ImmediateDownlineCount,
RecruitProximity)
SELECT DistNo, Sponsor, TreeLevel, DownlineCount, ImmediateDownlineCount, 0 FROM Recruit WHERE DistNo = @RootSponsorToDrill



SET NOCOUNT ON

DECLARE @StackDist TABLE
(
StackDepth INT,
Ndx INT,
DistNo VARCHAR(10),
ImmediateDownlineCount INT
)

DECLARE @StackCounter TABLE
(
StackDepth INT,
I INT,
N INT
)



DECLARE @StackDepth INT
SET @StackDepth = 1

goDrill:

--- push all dist of sponsor, stackdepth..
DECLARE @N INT

SET @N = 0
DECLARE @c CURSOR
SET @C = CURSOR FOR
SELECT DistNo, DownlineCount FROM Recruit WHERE Sponsor = @SponsorToDrill
OPEN @C

DECLARE @DistNo VARCHAR(10)
DECLARE @ImmediateDownlineCount INT

FETCH NEXT FROM @C INTO @DistNo, @ImmediateDownlineCount
WHILE @@FETCH_STATUS = 0 BEGIN


INSERT INTO @StackDist(StackDepth, Ndx, DistNo, ImmediateDownlineCount)
SELECT @StackDepth, @N, @DistNo, @ImmediateDownlineCount
SET @N = @N + 1
FETCH NEXT FROM @C INTO @DistNo, @ImmediateDownlineCount
END
CLOSE @C
DEALLOCATE @C
-- ..push all dist of sponsor, stackdepth

DECLARE @I INT

SET @I = 0
INSERT INTO @Drills(
DistNo,
Sponsor,
TreeLevel,
DownlineCount,
ImmediateDownlineCount,
RecruitProximity)
SELECT DistNo, Sponsor, TreeLevel, DownlineCount, ImmediateDownlineCount, @StackDepth FROM Recruit WHERE Sponsor = @SponsorToDrill

goProcess:
WHILE @I < @N BEGIN


declare @s varchar(800)
select @s = REPLICATE('-',@StackDepth * 2) + DistNo FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I
print @s


IF (SELECT ImmediateDownlineCount FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I) > 0 BEGIN
-- push i, n, stackdepth..
INSERT INTO @StackCounter(StackDepth, I, N) SELECT @StackDepth, @I, @N

SELECT @SponsorToDrill = DistNo FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I

SET @StackDepth = @StackDepth + 1

GOTO goDrill
-- ..push i, n, stackdepth
END
SET @I = @I + 1
END


IF @StackDepth > 1 BEGIN
DELETE FROM @StackDist WHERE StackDepth = @StackDepth


DELETE FROM @StackCounter WHERE StackDepth = @StackDepth
SET @StackDepth = @StackDepth - 1
-- pop I, N..
SELECT @I = I + 1, @N = N FROM @StackCounter WHERE StackDepth = @StackDepth

-- ..pop I, N

GOTO goProcess
END

SET NOCOUNT OFF





--SELECT * FROM @Drills order by sponsor

recruiting networking system

/*
features:
* have DownlineCount
* have ImmediateDownlineCount
* have Treelevel

Reporting:
* have downline's proximity indicator
* can drill anywhere in the tree
*/

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TrigInsOnRecruit]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
drop trigger [dbo].[TrigInsOnRecruit]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TrigDelOnRecruit]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
drop trigger [dbo].[TrigDelOnRecruit]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TrigUpdOnRecruit]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
drop trigger [dbo].[TrigUpdOnRecruit]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DrillDownlines]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[DrillDownlines]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Recruit]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Recruit]
GO

CREATE TABLE [dbo].[Recruit] (
[DistNo] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Sponsor] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[TreeLevel] [int] NOT NULL ,
[DownlineCount] [int] NOT NULL ,
[ImmediateDownlineCount] [int] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Recruit] WITH NOCHECK ADD
CONSTRAINT [PK_Recruit] PRIMARY KEY CLUSTERED
(
[DistNo]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Recruit] WITH NOCHECK ADD
CONSTRAINT [DF_Recruit_Sponsor] DEFAULT (space(0)) FOR [Sponsor],
CONSTRAINT [DF_Recruit_TreeLevel] DEFAULT (1) FOR [TreeLevel],
CONSTRAINT [DF_Recruit_DownlineCount] DEFAULT (0) FOR [DownlineCount],
CONSTRAINT [DF_Recruit_ImmediateDownlineCount] DEFAULT (0) FOR [ImmediateDownlineCount],
CONSTRAINT [CK_Recruit] CHECK ([DistNo] <> '')
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE DrillDownlines
@RootSponsorToDrill VARCHAR(10)

AS

/* we could have opt for a simpler version, and use recursive procedure, but since there is a limit on recursive depth of ms sql server's stored proc, which is 32, we instead use explicit stack */

DECLARE @SponsorToDrill VARCHAR(10)
SET @SponsorToDrill = @RootSponsorToDrill

DECLARE @Drills TABLE
(
DistNo VARCHAR(10),
Sponsor VARCHAR(10),
TreeLevel INT,
DownlineCount INT,
ImmediateDownlineCount INT,
RecruitProximity INT
)


INSERT INTO @Drills(
DistNo,
Sponsor,
TreeLevel,
DownlineCount,
ImmediateDownlineCount,
RecruitProximity)
SELECT DistNo, Sponsor, TreeLevel, DownlineCount, ImmediateDownlineCount, 0 FROM Recruit WHERE DistNo = @RootSponsorToDrill



SET NOCOUNT ON

DECLARE @StackDist TABLE
(
StackDepth INT,
Ndx INT,
DistNo VARCHAR(10),
ImmediateDownlineCount INT
)

DECLARE @StackCounter TABLE
(
StackDepth INT,
I INT,
N INT
)



DECLARE @StackDepth INT
SET @StackDepth = 1

goDrill:

--- push all dist of sponsor, stackdepth..
DECLARE @N INT

SET @N = 0
DECLARE @c CURSOR
SET @C = CURSOR FOR
SELECT DistNo, DownlineCount FROM Recruit WHERE Sponsor = @SponsorToDrill
OPEN @C

DECLARE @DistNo VARCHAR(10)
DECLARE @ImmediateDownlineCount INT

FETCH NEXT FROM @C INTO @DistNo, @ImmediateDownlineCount
WHILE @@FETCH_STATUS = 0 BEGIN
INSERT INTO @StackDist(StackDepth, Ndx, DistNo, ImmediateDownlineCount)
SELECT @StackDepth, @N, @DistNo, @ImmediateDownlineCount
SET @N = @N + 1
FETCH NEXT FROM @C INTO @DistNo, @ImmediateDownlineCount
END
CLOSE @C
DEALLOCATE @C
-- ..push all dist of sponsor, stackdepth

DECLARE @I INT

SET @I = 0
INSERT INTO @Drills(
DistNo,
Sponsor,
TreeLevel,
DownlineCount,
ImmediateDownlineCount,
RecruitProximity)
SELECT DistNo, Sponsor, TreeLevel, DownlineCount, ImmediateDownlineCount, @StackDepth FROM Recruit WHERE Sponsor = @SponsorToDrill

goProcess:
WHILE @I < @N BEGIN
IF (SELECT ImmediateDownlineCount FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I) > 0 BEGIN
-- push i, n, stackdepth..
INSERT INTO @StackCounter(StackDepth, I, N) SELECT @StackDepth, @I, @N

SELECT @SponsorToDrill = DistNo FROM @StackDist WHERE StackDepth = @StackDepth AND Ndx = @I

SET @StackDepth = @StackDepth + 1

GOTO goDrill
-- ..push i, n, stackdepth
END
SET @I = @I + 1
END


IF @StackDepth > 1 BEGIN
DELETE FROM @StackDist WHERE StackDepth = @StackDepth


DELETE FROM @StackCounter WHERE StackDepth = @StackDepth
SET @StackDepth = @StackDepth - 1
-- pop I, N..
SELECT @I = I + 1, @N = N FROM @StackCounter WHERE StackDepth = @StackDepth

-- ..pop I, N

GOTO goProcess
END

SET NOCOUNT OFF





SELECT * FROM @Drills


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

CREATE TRIGGER TrigInsOnRecruit ON [dbo].[Recruit]
FOR INSERT
AS


DECLARE @DistNo VARCHAR(10)
DECLARE @Sponsor VARCHAR(10)

SELECT @DistNo = DistNo FROM inserted
SELECT @Sponsor = Sponsor FROM inserted

IF @DistNo = @Sponsor BEGIN
RAISERROR( 'Distirbutor''s sponsor cannot be itself',16,1)
ROLLBACK TRAN
RETURN
END


UPDATE Recruit SET TreeLevel = RecruitSponsor.TreeLevel + 1
FROM Recruit
INNER JOIN inserted
ON Recruit.DistNo = inserted.DistNo
INNER JOIN Recruit AS RecruitSponsor
ON inserted.Sponsor = RecruitSponsor.DistNo



UPDATE Recruit SET ImmediateDownlineCount = ImmediateDownlineCount + 1
WHERE DistNo = @Sponsor


WHILE @Sponsor <&gt '' BEGIN

DECLARE @SponsorSponsor VARCHAR(10)


UPDATE Recruit SET DownlineCount = DownlineCount + 1
WHERE DistNo = @Sponsor

SELECT @SponsorSponsor = Sponsor
FROM Recruit
WHERE DistNo = @Sponsor


SET @Sponsor = @SponsorSponsor

END





GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE TRIGGER TrigDelOnRecruit ON [dbo].[Recruit]
FOR DELETE
AS


IF EXISTS( SELECT * FROM Recruit WHERE Sponsor = (SELECT DistNo FROM deleted) ) BEGIN

RAISERROR('Have downline can not be deleted', 16, 1)
ROLLBACK
RETURN
END


DECLARE @Sponsor VARCHAR(10)

SELECT @Sponsor = Sponsor
FROM deleted



UPDATE Recruit SET TreeLevel = RecruitSponsor.TreeLevel - 1
FROM Recruit
INNER JOIN deleted
ON Recruit.DistNo = deleted.DistNo
INNER JOIN Recruit AS RecruitSponsor
ON deleted.Sponsor = RecruitSponsor.DistNo


UPDATE Recruit SET ImmediateDownlineCount = ImmediateDownlineCount - 1
WHERE DistNo = @Sponsor



WHILE @Sponsor <> '' BEGIN

DECLARE @SponsorSponsor VARCHAR(10)


UPDATE Recruit SET DownlineCount = DownlineCount - 1
WHERE DistNo = @Sponsor

SELECT @SponsorSponsor = Sponsor
FROM Recruit
WHERE DistNo = @Sponsor


SET @Sponsor = @SponsorSponsor

END






GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

CREATE TRIGGER TrigUpdOnRecruit ON [dbo].[Recruit]
FOR UPDATE
AS


IF (SELECT DistNo FROM deleted) <&gt (SELECT DistNo FROM inserted) BEGIN
RAISERROR('Do not update this column',16,1)
ROLLBACK
RETURN
END




DECLARE @Sponsor VARCHAR(10)
DECLARE @DistNo VARCHAR(10)
DECLARE @DownlineCount INT

SELECT @DistNo = DistNo FROM inserted
SELECT @Sponsor = Sponsor, @DownlineCount = DownlineCount FROM deleted

DECLARE @NewSponsor VARCHAR(10)
SELECT @NewSponsor = Sponsor FROM inserted


IF @DistNo = @NewSponsor BEGIN
RAISERROR( 'Distirbutor''s sponsor cannot be itself',16,1)
ROLLBACK TRAN
RETURN
END



UPDATE Recruit SET TreeLevel = RecruitSponsor.TreeLevel + 1
FROM Recruit
INNER JOIN inserted
ON Recruit.DistNo = inserted.DistNo
INNER JOIN Recruit AS RecruitSponsor
ON inserted.Sponsor = RecruitSponsor.DistNo



UPDATE Recruit SET ImmediateDownlineCount = ImmediateDownlineCount - 1
WHERE DistNo = @Sponsor


UPDATE Recruit SET ImmediateDownlineCount = ImmediateDownlineCount + 1
WHERE DistNo = @NewSponsor



WHILE @Sponsor <> '' BEGIN

DECLARE @SponsorSponsor VARCHAR(10)


UPDATE Recruit SET DownlineCount = DownlineCount - 1 - @DownlineCount
WHERE DistNo = @Sponsor

SELECT @SponsorSponsor = Sponsor
FROM Recruit
WHERE DistNo = @Sponsor


SET @Sponsor = @SponsorSponsor

END






SELECT @Sponsor = @NewSponsor

WHILE @Sponsor <&gt '' BEGIN


UPDATE Recruit SET DownlineCount = DownlineCount + 1 + @DownlineCount
WHERE DistNo = @Sponsor

SELECT @SponsorSponsor = Sponsor
FROM Recruit
WHERE DistNo = @Sponsor


SET @Sponsor = @SponsorSponsor

END

















GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Tuesday, February 21, 2006

grammersoft with family at pansol

grammersoft at pansol

Monday, February 20, 2006

old-school left join, too quirky, sometimes result incorrectly. that's why ansi sql encourage the new left join

create table x
(
a int,
b int
)


create table y
(
a int
)


set nocount on

declare @a int, @b int

set @a = 1
while @a < 20 begin
insert into x(a,b) select @a, @a + 500000
insert into y(a) select @a / 2
set @a = @a + 1
end

insert into y(a) select null

-- query 1: using subquery
select *
from x
where x.a not in(select a from y where a is not null)
order by x.a

-- this join is equivalent to query 1 and is faster
select x.*
from x
left join y on x.a = y.a and y.a is not null
where y.a is null
order by x.a


/*
Note:

-- old way of left joining:
select x.* from x, y where x.a *= y.a

-- new way of left joining(ansi sql compliant):
select x.* from x left join y on x.a = y.a


but when you put other conditions in where clause in old-fashion left join(the *= ), things will get quirky, as you will see in the next queries result

*/

-- incorrect result, the quirks of old-way left join, not equivalent to query 1
select x.*, ya = Y.A
from x, y
where x.a *= y.a and y.a is null


-- incorrect result, still not equivalent to query 1
-- too quirky
select
*
from
(
select x.*, ya = Y.A
from x, y
where x.a *= y.a
) as z
where z.ya is null
order by z.ya

-- this is ok, equivalent to query 1
select
z.a, z.b
from
(
select top 100 percent x.*, ya = Y.A
from x, y
where x.a *= y.a
) as z
where z.ya is null
order by z.a

/* me wondering why have to put TOP 100 PERCENT in the subquery above */




/*
drop table x
drop table y
*/
set nocount off

Arctic Monkeys - Wikipedia, the free encyclopedia

Arctic Monkeys - Wikipedia, the free encyclopedia:

Record deals

All the while, the band were resisting the temptations of signing to a record deal, to the extent that record company scouts were barred from their gigs. Their logic - 'We've got this far without them - why should we let them in'[2], was illustrated with a series of sell-out gigs across the UK. October 2005 saw the band sell out the London Astoria, with 2000 fans singing the words to every song despite the band having released a single limited edition EP. Declaring their rampant rise to stardom via the Internet 'amazing', Turner added 'I'm sure one day it will come back and bite us in the arse'. The band's novel method of reaching the number 1 spot has led some to suggest that it could signal a change in how new bands achieve recognition. [3]

ang bagong table

at the mines view park

me at burnham park

Sunday, February 19, 2006

Unable to debug: The binding handle is invalid - MSDN Forums: "I had the same problem, solved it by disabling the 'Visual Studio hosting process'
('Project' -> '[ProjectName] Properties..'. -> 'Debug' -> Disable 'Enable the Visual Studio hosting process')

Whats the purpose of this 'Visual Studio hosting process' ?
"

C# sucks are you people blind - Dev Shed: "You obviously have no idea about java or C# since you can say such a stupidity.As for Microsoft 'stealing' tech from Sun please look at this:

1) 1996 Microsoft releases ASP; in 1998 Sun releases JSP
2) 1997 Microsoft releases ADSI; in 1998 Sun releases JNDI
3) 1997 Microsoft releases MSMQ; in 1998 Sun releases JMS
4) 1997 Microsoft releases Microsoft Transaction Server; in 1998 Sun releases EJB
5) 1998 Microsoft releases MSXML; in 2001 Sun releases JAXP
6) 2000 Microsoft releases Queued Components; in 2001 Sun releases Message Driven Beans
7) 2000 Microsoft releases XML Web Services; in 2001 Sun releases Java Web Services Developer Pack

So I ask who's playing catch-up?

This dates can be easily verified provided you know more about google.com than java/c#
I had this discussion so many times in the past i can't even remember how many.Most of the cases turns out the people I was talking to were a bunch of linux freaks hating everything microsoft.
Judging by how much proof you bring to support your views,I guess you fall under the same 'i hate microsoft,therefore I don't think before i speak about it' category.

/Chaos"

Java Sucks: "Here is the story of a poor soul who just needs to display 200 labels. And what does Java do, allocate 40 megabytes and never free it, naturally.

http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=1vgps6oteirco%24.a4bq78r09mww%24.dlg%4040tude.net&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.java.help

The funny thing is, garbage collection works very well in many other languages, such as C#, Python, and Lisp. What is it about Java that makes garbage collection so consistently suck across all platforms, virtual machines, and compilers?"

Saturday, February 18, 2006

Google Groups : dbase.reports:

From: BigMike - view profile
Date: Sat, Dec 29 2001 9:18 am
Email: "BigMike"
Groups: dbase.reports
Not yet rated
Rating:
show options

Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse | Find messages by this author

Hi All -

I'm using CRW 8.5. I must be missing a .DLL or have an out-of-date one
somewhere but I'm going nuts over this. Everything works OK in my attempt
to export a report. I click on the export button in the viewer and I get
the little box showing FORMAT:(PDF) and DESTINATION: Disk File.

All is well and good to this point. I click the OK button and I get the
Page Range screen - I select ALL and click on OK again. After that -
nothing. I am missing the "Choose export file" window/box where you name
the PDF file and advise where to put it. It works on my lap-top where I
hace CRW8.5 installed. It does NOT work where I do NOT have CRW8.5
installed. I don't want to install CRW8.5 - it must work without the
install.

So, I think it's a certain (unknown) Crystal file (.DLL or other) that I'm
having a problem with. Anybody have a clue.

Desperate.....Mike


From: Vic McClung - view profile
Date: Sat, Dec 29 2001 9:29 am
Email: "Vic McClung"
Groups: dbase.reports
Not yet rated
Rating:
show options

Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse | Find messages by this author

Hi Mike,

Have you read the Crystal Reports Developer Runtime Help file?

(From that file):

Export Destinations



If your application will give users the ability to export reports, you must
include files from the following list appropriate to the export destinations
provided:

FILE LOCATION DESCRIPTION
U2DAPP.DLL \WINDOWS\CRYSTAL Application destination
U2DDISK.DLL \WINDOWS\CRYSTAL Disk file destination
U2DMAPI.DLL \WINDOWS\CRYSTAL MAPI format (Microsoft Mail, Microsoft
Exchange)
U2DNOTES.DLL \WINDOWS\CRYSTAL Lotus Domino destination
U2DPOST.DLL \WINDOWS\CRYSTAL Microsoft Exchange Public Folders
U2DVIM.DLL \WINDOWS\CRYSTAL VIM destination

Export Formats



If your application will give users the ability to export reports, you must
include files from the following list appropriate to the export formats
provided:

FILE LOCATION DESCRIPTION
U2FCR.DLL \WINDOWS\CRYSTAL Crystal Reports format
U2FDIF.DLL \WINDOWS\CRYSTAL DIF format
U2FHTML.DLL \WINDOWS\CRYSTAL HTML formatSee HTML under Additional Components
for additional runtime information.
U2FODBC.DLL \WINDOWS\CRYSTAL ODBC data source
CRXF_PDF.DLL \WINDOWS\CRYSTAL PDF formatReplaces U2FPDF.DLL from version
8.See Page Ranged Export under Additional Components for additional runtime
information.
U2FRDEF.DLL \WINDOWS\CRYSTAL Report Definition format
U2FREC.DLL \WINDOWS\CRYSTAL Record format
CRXF_RTF.DLL \WINDOWS\CRYSTAL Rich Text FormatReplaces U2FRTF.DLL from
version 8 and earlier.See Page Ranged Export under Additional Components for
additional runtime information.
U2FSEPV.DLL \WINDOWS\CRYSTAL Comma Separated Values format
U2FTEXT.DLL \WINDOWS\CRYSTAL Text format
U2FWKS.DLL \WINDOWS\CRYSTAL Lotus 1-2-3 format
U2FWORDW.DLL \WINDOWS\CRYSTAL Microsoft Word for Windows format
U2FXML.DLL \WINDOWS\CRYSTAL XML format
U2FXLS.DLL \WINDOWS\CRYSTAL Microsoft Excel format

Page Ranged Export



The files listed are required when exporting to a format that allows you to
set a page range. These formats include:

· Rich Text Format using CRXF_RTF.DLL

· Portable Document Format using CRXF_PDF.DLL

FILE LOCATION DESCRIPTION
EXPORTMODELLER.DLL \PROGRAM FILES\SEAGATE SOFTWARE\SHARED Creates a
representation of the Crystal Encapsulated Page Format (EPF). The
representation is used by the export format DLL as a basis when translating
to it's own format.
CRTSLV.DLL \PROGRAM FILES\SEAGATE SOFTWARE\SHARED Used by EXPORTMODELLER.DLL
to process the EPF.

Note: ATL version 3.0 or higher must be on the users system.

"BigMike" wrote in message

news:a0j5md$97i$1@news.dbase.com...

- Hide quoted text -
- Show quoted text -
> Hi All -

> I'm using CRW 8.5. I must be missing a .DLL or have an out-of-date one
> somewhere but I'm going nuts over this. Everything works OK in my attempt
> to export a report. I click on the export button in the viewer and I get
> the little box showing FORMAT:(PDF) and DESTINATION: Disk File.

> All is well and good to this point. I click the OK button and I get the
> Page Range screen - I select ALL and click on OK again. After that -
> nothing. I am missing the "Choose export file" window/box where you name
> the PDF file and advise where to put it. It works on my lap-top where I
> hace CRW8.5 installed. It does NOT work where I do NOT have CRW8.5
> installed. I don't want to install CRW8.5 - it must work without the
> install.

> So, I think it's a certain (unknown) Crystal file (.DLL or other) that I'm
> having a problem with. Anybody have a clue.

> Desperate.....Mike



From: Mike Aadnesen - view profile
Date: Sun, Dec 30 2001 12:53 am
Email: "Mike Aadnesen"
Groups: dbase.reports
Not yet rated
Rating:
show options

Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse | Find messages by this author

Hi Vic -

I have done most of what you suggested but I will double check the files.
Question: are ANY of these DLLs supposed to be registered or is just putting
them in the suggested directories good enough?? Do I have to create a
\PROGRAM FILES\SEAGATE SOFTWARE\SHARED directory for some of the suggested
DLLs or can I put those DLLs in \Windows\System32 or \WINNT\System32
directory?

TIA,

BigMike


From: Vic McClung - view profile
Date: Sun, Dec 30 2001 4:48 am
Email: "Vic McClung"
Groups: dbase.reports
Not yet rated
Rating:
show options

Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse | Find messages by this author

"Mike Aadnesen" wrote in message

news:a0ksek$ftq$1@news.dbase.com...

> Hi Vic -

> I have done most of what you suggested but I will double check the files.
> Question: are ANY of these DLLs supposed to be registered or is just
putting
> them in the suggested directories good enough??

NOTE: You must register these DLLs using regsvr32.exe. ( if deployed)
CRAXDRT.DLL
CRVIEWER.DLL
CRAXDDRT.DLL
CRDESIGNERCTRL.DLL
CRYSTL32.OCX
EMFGEN.DLL
Here's one-->CRTSLV.DLL that has to be registered ( they don't say so)
Here's another-->EXPORTMODELLER.DLL, that they don't tell you but must
be registered and may very well be the ones causing your problem. Both the
above are used in exporting.

Do I have to create a

> \PROGRAM FILES\SEAGATE SOFTWARE\SHARED directory for some of the
suggested
> DLLs or can I put those DLLs in \Windows\System32 or \WINNT\System32
> directory?

The System directory. (maybe System on 9x/ME or System32 on NT/2K/XP)
I believe all go in the {win}\Crystal or {sys}\ directories.

- Hide quoted text -
- Show quoted text -

> TIA,

> BigMike



From: Mike Aadnesen - view profile
Date: Sun, Dec 30 2001 8:27 am
Email: "Mike Aadnesen"
Groups: dbase.reports
Not yet rated
Rating:
show options

Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse | Find messages by this author

Thank you so much Vic.....I'll get right on it.

As usual - the VDB News Group is on top of things.

I wish a Happy New Year to all - even the VB guys (boy, am I in a good
mood!)

BigMike

Tuesday, February 14, 2006

intepid » The Joy of Debugging:

The Joy of Debugging

Debugging software can be a bit like looking for your keys: More often than not, after hours of cursing and overturning furniture, you’ll find them in a really obvious place, where you could have sworn you had already looked.

There are no prizes for spotting the problem with the following code [especially if I tell you that the main symptom was incomplete or broken lines being drawn]:

void DrawPolyline(int nPoints, const Point* p)
{
for (int i = 0; i < nPoints - 1; i++)
DrawLine(p[0], p[1]);
}

Finding this bleeding obvious error took me a whole day! That’s a day of my life, which I will never get back.

[for the non-programmers, the error is that even though I create a loop to draw each segment of a polyline, I simply redraw the first segment over and over again… an easy error to make, but normally it would be detected almost immediately]

me, my brother, my sisters, my bro-in-law, cousins, pamangkins, and my tita at the mines view park

me at the baguio

PINAS: Tagalog, An'ng Say Mo?: "Tagalog: Ano'ng Say Mo?

Ang hindi magmahal sa sariling wika ay masahol pa sa malansang isda!
- Salawikaing Tagalog

ANG HIRAP lang, mahigit 150 ang mga wikang sinasarili sa ibat ibang pook ng Pilipinas, at maganang minahal namang lahat simula't simula pa. Ayon nga kay Frayle Pedro Chirino nuong 1602 pa,"...

Monday, February 13, 2006

my kolokoy brother and my pamangkin





Onion Tears: "Onion Tears

Date: Wednesday, September 21, 2005
Time: 3:28 AM EST
Kingropes
Country of Remedy: USA

Ingredients: Cold Water & 1 tablespoon salt
Instructions: Fill a shallow pan with cold water, and add the salt. Stir until dissolved.Cut the outer layer off of the onion, and let soak in the salted water for 10-15 minutes.Slice & dice as usual.

Date: Sunday, August 28, 2005
Time: 1:21 PM EST
Email address: Juanita Permenter
email_address: tigermarie@sbcglobal.net
Country of Remedy: Usa
Ingredients: 1 stick of chewing gum.
Instructions: Put the gum in your mouth and chew while you are cutting up the onion and it will not effect you.

Date: Tuesday, August 23, 2005
Time: 9:57 AM EST
Simon
Country of Remedy: New Zealand

Ingredients: One piece of sliced bread
Instructions: Hold bread in mouth so as you can see over it enough to not cut yourself.

Date: Sunday, August 21, 2005
Time: 6:07 AM EST
Juanita
Country of Remedy: United states

Ingredients: Chewing gum
Instructions: Just put a piece of gum in your mouth and start chewing and then start cutting up your onion.I promise this works. I was told about it and tried it. Now i have no more Onion Tears.

Date: Saturday, August 6, 2005
Time: 9:54 PM EST
livie
Subject: Home RemedyCountry of Remedy: canada

Ingredients: mint gum
Instructions: when you're chopping the onions, chew the gum constantly. works for me!

To prevent Onion Tears, hold your wrist under running cold water while cutting or peeling an onion and no more tears! If you have to move your wrist for a moment that's fine; return it to the running cold water when can and still no tears. Pretty Cool!

Date: Monday, May 16, 2005
Time: 3:00 PM EST
D. Charles
Country of Remedy: USA

Ingredients: one match or incense stick
Instructions: Just hold a match or incense stick in your mouth (red tip out) while you cut the onion and your eyes won't tear up at all."

Sunday, February 12, 2006

anatomy of decimal/numeric and float data type

ANATOMY OF FLOAT AND DECIMAL TYPE
(float's binary fraction vs decimal's fraction)



------------------------------


Don't (or never) use float/real/double/single for money data type, f/r/d/s's fractions have bad representation in binary.

Instead, use decimal/numeric or money(same as decimal/numeric type with only a fixed fraction of 4 decimal places), this is more faithful to pencil and paper representation/calculation of number, just takes up more space.



declare @t table(
f1 float,
m1 money,
n1 numeric(22,9),

f2 float,
m2 money,
n2 numeric(22,9)

)



declare @i int

set @i = 1

while @i <= 100 begin
insert into @t(f1,m1,n1, f2, m2,n2)
select 0.1, 0.1, 0.1, 0.7, 0.7, 0.7

set @i = @i + 1
end

select
f1 = sum(f1), m1 = sum(m1), n1 = sum(n1) ,
f2 = sum(f2), m2 = sum(m2), n2 = sum(n2)
from @t


results:

f1 m1 n1 f2 m2 n2
9.9999999999999805 10.0000 10.000000000 70.000000000000128 70.0000 70.000000000



floating: not accurate
for f1: one hundred 0.1 is 9.9999999999999805
for f2: one hundred 0.7 is 70.000000000000128


decimal/numeric: accurate
m1,n1: one hundred 0.1 is 10
m2,n2: one hundred 0.7 is 70


----------------------------------------------------------------------------

-- double precision float: double in vb6, double in pascal/delphi, double in C, double in java
declare @f float

-- single precision float: single in vb6, real in pascal/delphi, float in C, float in java
declare @r real

-- paper and pencil arithmetic
declare @d decimal(22,12) -- same as numeric(22,12)


----

set @f = 8.987654321
set @r = 8.987654321
set @d = 8.987654321




select f = @f, r = @r, d = @d
result:

f r d
8.9876543210000008 8.9876547 8.987654321000



f and r loss precisions
d is exact


----

set @f = 2.110519763456
set @r = 2.110519763456
set @d = 2.110519763456

select f = @f, r = @r, d = @d
result:

f r d
2.1105197634559998 2.1105196 2.110519763456



f and r loss precisions
d is exact


-----------------



declare @a float, @b float, @c float, @d float

set @a = 2.1
set @b = 4.1
set @c = 3.1
set @d = 7.1

select a = @a, b = @b, c = @c, d = @d


a b c d
2.1000000000000001 4.0999999999999996 3.1000000000000001 7.0999999999999996


------------


declare @t table
(
a float, b float, c float, d float, e float, f float
)


insert into @t select 21.4, 76.8, 7.4, 15.4, 7.2


select * from @t

a b c d e
21.399999999999999 76.799999999999997 7.4000000000000004 15.4 7.2000000000000002


----------------



floating point data types are not a bug when you are using them for games or scientific/engineering simulations, and like when computing the progress bar indicator.

where performance is a concern, like games, number's fraction approximation in float(binary) would suffice and are fast.

but for financial values, using float(a number type where fraction can't be accurately represented in binary) is risky.


float/real/double/single fractions cannot be represented accurately in binary (divisible by 2's),
some handful of fractions that can be represented exactly in floats(binary):
ex:

base 10: 7.5
base 2: 111.1 or 7 and 1/2; fraction: .1 = 1/2 = 0.5


base 10: 5.75
base 2: 101.11 or 5 and 3/4; fraction: .11 = 1/2 + 1/4 = 0.50 + 0.25 = 0.75

base 10: 125.125
base 2: 01111101.001 or 125 and 1/8: fraction: .001 = 0/2 + 0/4 + 1/8 = .125


base 10: 3.25
base 2: 11.01 or 125 and 1/4; fraction: .01 = 1/4 = .25


base 10: 9.1 .1 is not divisible by a divisor multiples of 2
base 2: 1001.???????? think of a number when you divide in multiple of 2 that would result in 0.1;
answer is... no exact divisor of multiple 2 would result in exact 0.1



based on the applet(see url below) the ideal divisor that is a multiple of 2 that would result in approximately 0.1 is 134,217,728.


decimal/numeric/currency/money are more faithful to paper and pencil arithmetic of numbers, just takes more space.


if you have a number like 4,000,000,000 this would take up 10 bytes with decimal type, or 5 bytes(if 2 digits per byte)

whereas if you represent 4 billion in int or float type, this would only takes up 4 bytes, and is faster to calculate and summed, yet inaccurate in fraction parts.



-----------------------


references:


floating point in binary:
http://www.python.org/doc/tut/node16.html


anatomy of floating point number:
http://en.wikipedia.org/wiki/IEEE_754



mainsail and floating point:
http://www.xidak.com/mainsail/other_documentation/floatingpoint.html


mysql: problem with floating point
http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html

--------------------------------------------------------------------------------------------

floating point simulations:

java applet for converting the representation of floating point number in binary:
http://www.h-schmidt.net/FloatApplet/IEEE754.html


too small divisor:

let's try small divisor for 0.1, let's say 1024

if we would only use a small divisor, let's say 1024, 1024 x 0.1 the dividend would become 102.4, omit the .4, 102


102 / 1024 = 0.099609375 = too low to be capable of representing 0.1

if the dividend is 103:
103 / 1024 = 0.1005859375 = too high to be a good representation of 0.1, the extraneous fractions(5859375) is too near in the significant digits


if we would only use a divisor of ten binary places(1024, 2 ^ 10) for 0.1, the binary representation of 0.1 would be far from ideal.

102 = .0001100110
103 = .0001100111

102 / 1024 = 0.099609375
103 / 1024 = 0.1005859375

conclusion: 0.1 can't be accurately represented with too small divisor



------------------

let's try a longer divisor..

32 BIT: mssql's real, c's float, java's float, delphi/pascal's real, vb6's single, postgresql's float4, mysql's float


using the above java applet guide, the ideal divisor would be 134,217,728(for 32 bit) and the dividend would 13,421,773


0.1 representation in binary:

134,217,728 (is a multiple of 2), or 2 ^ 27
13,421,773 divide by 134,217,728 =
0.100000001490116119384765625 (good enough representation of 0.1 in floating binary), 27 binary places(less than 32 bit)




divisor representation in binary: like the base 10 counterpart of 1/3 which doesn't have exact decimal fraction representation, or 0.3333333333..., the 0.1 don't also extends infinitely and doesn't have exact binary representation

000110011001100110011001101...



-------------------

let's try a more longer divisor..

64 BIT: mssql's float, c's double, java's double, delphi/pascal's double, vb6's double, postgresql's float8, mysql's double

let's try a big divisor, 64 bit. 56 binary places

2 ^ 56 = 72,057,594,037,927,936

7,205,759,403,792,793 / 72,057,594,037,927,936
= 0.099999999999999991673327315311326; even if we use big divisor but the choice of dividend is poor, we won't be able to accurately represent 0.1

7,205,759,403,792,795 / 72,057,594,037,927,936
= 0.10000000000000001942890293094024; this is better than the 32 bit version, the extraneous fractions(1942890293094024) are far from the significant digit



then when printing the 64 bit float, stop at let's say.. 8th decimal place, the internal value of 0.10000000000000001942890293094024 would be printed as 0.10000000, but still, under the hood, it still has extra fractions




note that sql server stops printing values at 17th decimal place:

declare @d float

set @D = 0.1
select @d

output: 0.10000000000000001

set @d = 0.98765
select @d

output: 0.98765000000000003



--------------------------------------


FINAL CONCLUSIONS:


1. floating values are hairy creatures too be viable for money type, even the double precision float.

2. just use decimal or currency data type for money values.





to use decimal/currency:


vb6:

use Currency(a decimal with a scale of 4)

or declare variable as variant and then assign it with cdec cast.

example:

Dim Total As Variant 'Decimal
Total = CDec(0.1)



simulate the code below in VB6:
Dim f As Double ' or try Single
f = 0
Dim x As Integer
For x = 1 To 1000
f = f + 0.1
Next
MsgBox f

then this one:
Dim f As Variant 'Decimal
f = CDec(0)
Dim x As Integer
For x = 1 To 1000
f = f + 0.1
Next
MsgBox f



access: use Currency

.net: just use the intrinsic decimal type

java: use the Decimal class

c: create decimal struct, then create function for it

c++: roll your own Decimal class, then overload operators

mssql: use decimal/numeric or money(decimal/numeric with only 4 scale)

postgresl: use numeric

mysql: use numeric

oracle: use decimal

php: di ko makita kung pano decimal type sa php, perhaps i should learn this again

Paul Thurrott's SuperSite for Windows: Windows XP Home Edition vs. Professional Edition, What's the difference?:

Windows XP Home Edition vs. Professional Edition: What's the difference?
Updated for the RTM release of Windows XP


With the inclusion of a new consumer-oriented version of Windows XP, there has been some confusion surrounding the differences between this product, Windows XP Home Edition, and its more upscale sibling, Windows XP Professional Edition. During a visit to Redmond in February where Windows XP Beta 2 and the new Whistler ("Luna") user interface was first unveiled, and in various meetings since then, I've been able to discuss this new Windows version with Microsoft executives and product managers. Beyond the obvious--Microsoft is targeting Home Edition at consumers and Professional at business users and power users--Group Vice President Jim Allchin said that the company was working hard to further differentiate the products. "With XP, the home version is what it is," Allchin said. "But where we're going, we've named them appropriately. In the future, this will make more sense. We will do more value add in Pro in the future."



"Divide them into managed and unmanaged environments," added John Frederiksen, the General Manager of the PC Experience Solution Group, noting that some smaller businesses would probably install Home Edition regardless of the target marketing. "Some small businesses have administrators, some don’t. Home Edition is not a managed OS. It's optimized for that consumer market. A lot of the OEM PCs marketed to consumers are bought by small businesses. In terms of naming, we wanted to continue the Professional name. For the consumer product, we tested the name Windows Me again, the year names, like Windows 2002, and a lot of other stuff. But Home Edition tested the best. The feedback said that Home Edition suggested it was customized for the home, which it was. We feel like the name reflects its purpose."

Windows XP Home Edition Overview
Windows XP Home Edition includes a number of enhancements over Windows 2000 Professional. These include:

* Improved software (application) and hardware compatibility
* Simplified security
* Simplified log-on featuring new "welcome" screen
* Fast user switching
* A new user interface featuring context-sensitive, task-oriented Web views
* Enhanced support for digital media (movies, pictures, music)
* DirectX 8.1 multimedia libraries for gaming

Professional Edition: Superset of Home Edition
At its most basic level, XP Professional is a business- and power-user oriented superset of Home Edition. Because this orientation, it includes features that wouldn't be appropriate, or would be too complex, for the typical home user. The most obvious difference is security, which is vastly simplified in Home Edition. Each interactive user in XP Home is assumed to be a member of the Owners local group, which is the Windows XP equivalent of the Windows 2000 Administrator account: This means that anyone who logs on to a Home Edition machine has full control. Likewise, the Backup Operators, Power Users, and Replicator groups from Windows 2000/XP Pro are missing from Home Edition, and a new group, called Restricted Users, is added. Hidden administrative shares (C$, etc.) are also unavailable in Home Edition.

"Professional Edition is a strict superset of Home Edition," confirmed Chris Jones, Vice President of the Windows Client Group. "Everything you can do in Home Edition, you can do in Pro. So we do think there are home users who will buy Pro." Jones' distinction is a good one: With Windows XP, the Professional Edition is finally a superset of all the desktop clients that came before (Windows Me and Windows 2000 Professional) as well as of its new sibling. So when discussing the differences between the editions, it's best to simply describe those features in Pro that you can't get in Home Edition.

Pro features that aren't in Home Edition
The following features are not present in Windows XP Home Edition.

* Power user Remote Desktop - All versions of Windows XP--including Home Edition--support Remote Assistance, which is an assisted support technology that allows a help desk or system administrator to remotely connect to a client desktop for troubleshooting purposes. But Only Pro supports the new Remote Desktop feature, which is a single-session version of Terminal Services with two obvious uses: Mobile professionals who need to remotely access their corporate desktop, and remote administration of clients on a network. You can access a Windows XP Remote Desktop from any OS that supports a Terminal Services client (such as Windows 98 and, interestingly XP Home). XP Home can act as the client in a Remote Desktop session; only Pro can be the server.
* Multi-processor support - Windows XP Pro supports up to two microprocessors, while Home Edition supports only one.
* Automated System Recovery (ASR) - In a somewhat controversial move, Microsoft has removed the Backup utility from the default Windows XP Home Edition, though it is available as an optional installation if you can find it on the CD-ROM (hint: it's in the /valueadd folder). The reason for this the integration of Microsoft's new Automated System Recovery (ASR) tool into Backup. In Pro, ASR will help recover a system from a catastrophic error, such as one that renders the system unbootable. ASR-enabled backups are triggerable from XP Setup, allowing you to return your system to its previous state, even if the hard drive dies and has to be replaced. Unlike consumer-oriented features such as System Restore, ASR is not automatic: It must manually be enabled from within the Backup utility in Windows XP Pro. In any event, while there is a Backup utility available for Home Edition, you cannot use ASR, even though mentions of this feature still exist in the UI. Confusing? Yes. But it's better than no Backup at all, which was the original plan.
* Dynamic Disk Support - Windows XP Professional (like its Windows 2000 equivalent) supports dynamic disks, but Home Edition does not (instead, HE supports only the standard Simple Disk type). Dynamic disks are not usable with any OS other than Windows 2000 or Windows XP Pro, and they cannot be used on portable computers. Likewise, Home Edition does not include the Logical Disk Manager.
* Fax - Home Edition has no integrated fax functionality out of the box, though it is an option you can install from the XP Home CD.
* Internet Information Services/Personal Web Server - Home Edition does not include the IIS Web server 5.1 software found in Pro.

* Security Encrypting File System - Windows XP Professional supports the Encrypting File System (EFS), which allows you encrypt individual files or folders for local security (EFS is not enabled over a network). EFS-protected files and folders allows users to protect sensitive documents from other users.
* File-level access control - Any user with Administrator privileges can limit access to certain network resources, such as servers, directories, and files, using access control lists. Only Windows XP Professional supports file-level access control, mostly because this feature is typically implemented through Group Policy Objects, which are also not available in Home Edition.
* "C2" certification - Microsoft will attempt to have Windows XP Professional certified with the "C2" security designation, a largely irrelevant status, but one which will not be afforded to Home Edition.

* Management Domain membership - Home Edition cannot be used to logon to an Active Directory domain. For obvious reasons, the Domain Wizard is also missing in Home Edition.
* Group Policy - Since Home Edition cannot be used to logon to an Active Directory domain, Group Policy--whereby applications, network resources, and operating systems are administered for domain users--is not supported either.
* IntelliMirror - Microsoft lumps a wide range of semi-related change and configuration management technologies under the IntelliMirror umbrella, and none of these features are supported in the consumer oriented Home Edition. IntelliMirror capabilities include user data management; centrally-managed software installation, repair, updating, and removal; user settings management; and Remote Installation Services (RIS), which allows administrators to remotely install the OS on client systems.
* Roaming profiles - This feature allows users to logon to any computer in an Active Directory network and automatically receive their customized settings. It is not available in Home Edition, which cannot logon to an Active Directory domain.

* Corporate deployment Multi-language support - Only Windows XP Professional will ship in a Multi-Language version or support multiple languages in a single install.
* Sysprep support - Windows XP Pro will support the System Preparation (Sysprep) utility, while Home Edition will not.
* RIS support - See the IntelliMirror heading in the previous section; Home Edition does not support RIS deployments.

* 64-bit Edition Microsoft is shipping a 64-bit version of Windows XP for Intel Itanium systems that mirrors the Professional Edition feature-set.

Networking features
* The following networking features are not included in Home Edition: The user interface for IPSecurity (IPSec)
* SNMP
* Simple TCP/IP services
* SAP Agent
* Client Service for NetWare
* Network Monitor
* Multiple Roaming feature

User interface features
* Windows XP Home Edition has some different default settings that affect the user interface. For example, Guest logon is on by default in Home, but off in Pro. The Address bar in Explorer windows is on in Pro by default, but off in Home. During the beta period, Microsoft had intended to use a business-oriented shell theme ("Professional") by default in Pro and the "Luna" consumer theme in Home Edition. But feedback from corporate users suggested that everyone liked the consumer-oriented Luna theme better, and development of the Professional theme was cancelled. Other user interface features that are present in Pro but not Home include: Client-side caching
* Administrative Tools option on the Start menu (a subset of the Admin tools are still present in Home, however).

It's also worth mentioning that Home Edition will support upgrades from Windows 98, 98 SE, and Millennium Edition (Me), but not from Windows 95, NT 4.0 Workstation, or Windows 2000 Professional. You can upgrade from Windows 98, 98 SE, Millennium Edition (Me), Windows NT 4.0 Workstation, or Windows 2000 Professional to Windows XP Professional. See my article on What to Expect from Windows XP for more information.

Deciding which edition to buy is simple: Peruse the above list and decide whether you can live without any of these features. If you can't, then you're going to want to get Professional. Otherwise, save $100 and get Home Edition. Note that Microsoft is offering a less-expensive Professional "Step-Up" upgrade for Home users that wish to move to XP Pro.

Wednesday, February 08, 2006

katie vs. the philippines: Kababata ba kita?:

Noong ikaw ay bata pa, nagawa mo ba ang mga sumusunod?...

*kumakain ka ba ng aratilis?

*nagpipitpit ng gumamela para gawing soapy bubbles na hihipan mo sa binilog na tangkay ng walis tingting?

*pinipilit ka ba matulog ng nanay mo pag hapon at di ka papayagan maglaro pag di ka natulog?

*marunong ka magpatintero, saksak puso, langit-lupa, teleber-teleber, luksong tinik?

*malupit ka pag meron kang atari, family computer or nes?

*alam mo ang silbi ng up, up, down, down, left, right, left, right, a, b, a, b, start?

*may mga damit ka na U.S.E.D., Boy London, Cross Colors, Esprit, Blowing Bubbles at pag nakakakita ka ng Bench na damit eh naalala mo si Richard Gomez?

*addict ka sa rainbow brite, carebears, my little pony, thundercats, bioman, voltes v, mazinger z, daimos, he-man at marami pang cartoons na hindi pa translated sa tagalog?

*nanonood ka ng shaider kasi nabobosohan mo si annie at type na type mo ang puting panty nya?

*marunong ka mag wordstar at nakahawak ka na talaga ng 5.25 na floppy disk?

*inaabangan mo lagi ang batibot at akala mo magkakatuluyan si kuya bodgie at ate sienna... nung high school ka inaabangan mo lagi beverly hills 90210?

*gumagamit ka ng AQUANET para pataasin ang bangs mo?

*meron kang blouse na may padding kung babae ka at meron kang sapatos na mighty kid kung lalake ka?

*nangongolekta ka ng paper stationaries at mahilig ka magpapirma sa slumbook mo para lang malaman mo kung sino ang crush ng type mo?

*kilala mo si manang bola at ang sitsiritsit girls?e si luning-ning at luging-ging?

*alam mo ibig sabihin ng time space warp at di mo makakalimutan ang time space warp chant?

*idol mo si McGyver at nanonood kang Perfect Strangers?

*eto malupet... six digits! lang ba ang phone number nyo dati?

*nakakatawag ka pa sa pay phone ng 3 bente singko lang ang dala?

*cute pa si aiza seguerra sa eat bulaga at alam mo ang song na "eh kasi bata"?

*inabutan mo ba na ang Magnolia Chocolait eh nasa glass bottle pa na ginagawang lalagyan ng tubig ng nanay mo sa ref?

*meron kang pencil case na maraming compartments na pinagyayabang mo sa mga kaklase mo?

*noon mo pa hinahanap kung saan ang Goya Fun Factory?

*alam mo lyrics ng "tinapang bangus" at "alagang-alaga namin si puti"?

*alam mo ang kantang "gloria labandera".. lumusong sha sa tubig ang paa ay nabasa at ang "1, 2, 3, asawa ni marie"?

*sosyal ka pag may play-doh ka at Lego... at nag-iipon ka ng G.I. Joe action figures at iba pa ang mukha ni barbie noon?

*inabutan mo pa yung singkong korteng bulaklak at yung diyes na square?

*lumaki kang bobo dahil ang akala mo nangangagat talaga ang alimango sa kantang tong-tong-tong... di ba naninipit yun?

*alam mo yung kwento ng pari na binigyan ng pera yung batang umakyat ng puno para bumili ng panty... and shempre, alam mo rin ba kung ano binigay nya sa nanay nung umakyat ng puno?

*meron kang kabisadong kanta ni Andrew E na alam mo hanggang ngayon.. aminin?

*laging lampin ang sinasapin sa likod mo pag pinapawisan ka?

*bumibili ka ng tarzan, texas at bazooka bubble gum... tira-tira, at yung kending bilog na sinawsaw sa asukal?

*kinukupit mo pa at nanonood ka ng mga porno tapes ng tatay mo na nasa BETAMAX format pa... at sanay ka tawagin ang porn as BOLD?

*takot ka dumating ang year 2000 dahil sabi nila magugunaw daw ang mundo?

*naaalala mo pa na mas masarap ang mellow yellow kaysa mountain dew?

*75 cents pa ang pamasahe n'un?

If so, then you must be 25-30 years old by now. Hahaha! Love to remember the good old times. *SIGH!*

Bill's House O Insomnia : Spot the VB6 Programmer:

My absolute most hated VB user is the dreaded "corporate analyst" who knows just enough to be really dangerous. They say things to their boss like "sure I can have a CRM application that uses Sql Server up and going in a few weeks" deadline comes and they have their basic connection code up and going and not much more. So they come downstairs to the lab where I work and see which research developer they can try and con into helping them. If that fails shortly afterwards their boss will go speak to our boss about "getting someone to help them out with a small project they are having trouble with". Our boss will have us go take a look and we come back and tell him that not only is it not a small project what they have so far is a VBA app in Excel that populates the wrong part of a spread sheet with the wrong data from Sql Server. Yes, that's right they tried to write it in Excel VBA. Think I'm joking I can e-mail you code straight out of their stupid projects. I save some of the really bad stuff to use as examples of what not to do. Such as If Then Else statements nested 18 deep in a time critical loop, etc.

Tuesday, February 07, 2006

ANN: "Oddly, though, the day's tragedy seemed to reveal something bizarre in the Filipino psyche: Instead of going home, thousands of Wowowee fans who made it to the stadium before the stampede decided to stay put, holding on to their tickets and their seats, still hoping the show would go on."


ABS-CBN Forums -> Wowowee ULTRA Tragedy: "The Ultra stampede doesn't fit into the global pattern. What we have here is something that was described several decades ago by an American anthropologist, George Foster, as 'the image of limited good,' the idea that certain 'good' resources are limited. He was studying a Mexican village and noted that whenever someone experienced good fortune -- sudden wealth, for example -- rumors spread that the person had entered into a pact with the Devil."

Sunday, February 05, 2006

Voice of the Voiceless:

Magaling Ako Magpaliwanag

Paumanhin sa aking mga mamboboso..este, mambabasa pala. Hindi po nakapaglathala kahapon ang inyong lingkod dahil ang asawa ko ay isang "adik." Kundi ba sya adik, bigla ba naman nagtrip kahapon at niyaya akong magswimming! Wala man lang kaming plano para sa bagay na yun pero syempre tuloy pa din kami kasi pag di ako pumayag, awtsayd de kulambo ako. Buti nga sa Pansol lang ako niyaya at hindi sa Hawaii kasi wala ako pasaporte. Adik sya di bah!!!
Pag-uwi namin kagabi, syempre binisita ko agad ito, nakita ko ang mga komento dun sa inilathala ko tungkol kay budo at napukaw ang aking pansin sa sinabi nung isa na samahan ko daw ulit si budo na humanap ng trabaho baka daw kasi lagi ako nitong katukin at magpalibre sa akin, syempre natakot ang inyong lingkod, isipin nyo araw-araw ko syang makikita. Ang ginawa ko, kinuha ang classified pages ng manila bulletin na binili ko nung nakaraang taon at pinuntahan ko si budo. Sabi ko sa kanya, pre, kaysa pumila tayo kahapon, ito ang dyaryo hahanapan kita ng trabaho. Syempre pasalamat agad sya sa kin kasi concern ako sa kanya. Hanap agad sya siempre. Napansin niya na karamihan call center ang nandoon. Tanong niya sakin, pre, pwede ba ko dito sa call center? Sagot ko, Oo pre, sakto yan sa isang tulad mo, sa telepono ka lang maghapon, di ka kasi pwede sa field na katulad ko, walang haharap sau...hehehe! Syempre, naging interesado ang loko, aplayan daw nya agad. Sinabihan ko sya, itsek mo muna kung ang ibang mga qualifications ay akma sa iyo. Dahil bobo nga siya, ipinaubaya niya sakin ang pagbabasa at ipaliwanag ko daw sa kaniya pagkatapos. E di wala nako magawa kundi ipaliwanag nga sa kanya. Heto ang ilan sa mga ginawa kong paliwanag sa kanya:

1. Requires team leadership skills. Pre, manager ang dating mo dito. Lahat ng responsibilidad ng isang manager, ikaw ang hahawak. Hindi nga lang pangmanager ang sweldo at ang respetong ibibigay sayo.

2. Problem solving a must. Pre, mukhang babagsak na ang kumpanyang aaplayan mo kasi naghahanap na sila ng gagawa ng solusyon sa mga problemang kinahaharap nila.

3. Must have an eye for detail. Swerte mo dito pre, wala silang QC (quality control).

4. Duties will vary. Madaming trabaho masyado. Kailangan handa ka sa iuutos ng lahat ng tao sa opis.

5. Must be flexible. Kailangan malambot ang katawan mo pre. Ipaaabot ang ulo mo sa talampakan mo para maentertain ang mga kliyente.

6. Must be deadline oriented. Ok to pre, behind skedyul ka ng anim na buwan.

7. Willing to work at night. Alanganin ako dito pre, baka akyat-bahay ang mapasukan mo.

8. 18 and above. Buti walang age limit pre.

9. Career-minded. Kalimutan mo nang may pamilya ka pag napasok ka dito.

10. Seeking candidates with a variety of experience. Kailangan eksperyensado ka na kasi papalitan mo ung siyam na daang taong humawak na sa posisyon na yan at di nagtagal.

11. Work in a fast paced environment. Trabaho agad wala nang training.

Syempre kahit sinong tangang taong katulad ng kaibigan ko magdadalawang isip na sa ginawa kong paliwanag kaya sabi nya sakin, di na lang daw sya tutuloy. E makulit nga ko kaya pinilit ko pa rin sya. Sabi ko, magaganda naman ang offer nila sa sinumang matatanggap eh. Pinaliwanag ko naman sa kanya ang mga luxury na matatamo nya pag natanggap sya. Heto naman ang mga yun:

1. Competitive salary. Di sila katulad ng ibang kumpanya na nagpapasweldo ng tama. Pahirapan dun tuwing akinse.

2. Casual work atmosphere. Tipid ka sa damit kasi kahit ano pwede mo isuot. Di naman sila magbibigay ng dagdag na sweldo kapag maganda ang suot mo.

3. Life insurance. Di ata to luxury kasi pagbebentahin ka daw ng insurance pre.

4. Free transportation. Araw-araw kang palipat-lipat ng cubicle kasi di kabibigyan ng sarili mo.

5. Free meal. Meron kayong pulburon at machakaw araw-araw.

5. Bonus + commissions for Outbound positions. Swerte mo meron ka aasahan bonus kaso tuwing pasko lang ibibigay sau. Ok lang yun ilang months na lang naman eh.

Alam nyo kung ano ginawa ni budo matapos ang lahat ng maganda kong paliwanag? Aba, natulog na lang ang loko. Nahilo ata sa pinagsasabi ko. Ganda nga ng paliwanag ko sa kanya eh. Ay naiwan nga pala niya ung resume niya skin, gusto mo ishare ko sau? Ako naman ang gumawa nun para sa kanya eh. Heto basahin mo:

Name: Potiolo Palacudio
Nickname: Budo sometimes Piolo
Sex: Unisex Age: N/A
Mobile number: still using pager - 1511231554
Education: College, June 1979-March 2005
Work Experience: Instrumental in ruining entire operation of a multi-million company
Reason for leaving previous job: Responsibility makes me nervous
Personal Qualities
Marital Status: Often Children: Various
Number of dependents: 40
Special Request:
Please call me after 5:30pm because I am self-employed and my employer doesn't know I am looking for another job.
Reference: Major Kontrapelo - Business Coordinator - 091943664.... - Tondo, Manila


Astig ung resume niya noh! Kung ako ang employer, pupunitin ko yan sa harap niya...hehehe!!!