Showing posts with label includes. Show all posts
Showing posts with label includes. Show all posts

Tuesday, March 20, 2012

Data Recovery Book

Hi!
I am glad to introduce World's First Book on Professional Data
Recovery Programming. Book also Includes a FREE CD, which contains
complete Source Codes of all the software/Programs described within
the book and may interesting tools
You can see the contents of the book and order Online on following
link:
http://www.DataDoctor.biz/author.htm
The Details of the Book are as follows:
Title of the book: "Data Recovery with & without Programming"
Author of the book: Tarun Tyagi
Publishers of the book: BPB Publications, New Delhi, India
Number of Pages: 540
Size: (9.5 x 7.5 x 1.0) Inches
ISBN: 81-7656-922-4
Price: $ 69.00 (Including Shipping Charge, Cost of
Book and Other expenses)
Enjoy Reading!!
Regards,
Tarun Tyagi
J-110, Patel Nagar - 1,
Ghaziabad (U.P.), India -201001
Cell: (+91)9868337762
http://www.DataDoctor.Biz
Your page doesn't render at all in Firefox. You might want to check that
out.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"Author Tarun Tyagi" <tyagi_st@.yahoo.com> wrote in message
news:a921f5f5.0412010120.1b976a90@.posting.google.c om...
> Hi!
> I am glad to introduce World's First Book on Professional Data
> Recovery Programming. Book also Includes a FREE CD, which contains
> complete Source Codes of all the software/Programs described within
> the book and may interesting tools
> You can see the contents of the book and order Online on following
> link:
> http://www.DataDoctor.biz/author.htm
> The Details of the Book are as follows:
> Title of the book: "Data Recovery with & without Programming"
> Author of the book: Tarun Tyagi
> Publishers of the book: BPB Publications, New Delhi, India
> Number of Pages: 540
> Size: (9.5 x 7.5 x 1.0) Inches
> ISBN: 81-7656-922-4
> Price: $ 69.00 (Including Shipping Charge, Cost of
> Book and Other expenses)
> Enjoy Reading!!
> Regards,
> Tarun Tyagi
> J-110, Patel Nagar - 1,
> Ghaziabad (U.P.), India -201001
> Cell: (+91)9868337762
> http://www.DataDoctor.Biz

Data Recovery Book

Hi!
I am glad to introduce World's First Book on Professional Data
Recovery Programming. Book also Includes a FREE CD, which contains
complete Source Codes of all the software/Programs described within
the book and may interesting tools
You can see the contents of the book and order Online on following
link:
http://www.DataDoctor.biz/author.htm
The Details of the Book are as follows:
Title of the book: "Data Recovery with & without Programming"
Author of the book: Tarun Tyagi
Publishers of the book: BPB Publications, New Delhi, India
Number of Pages: 540
Size: (9.5 x 7.5 x 1.0) Inches
ISBN: 81-7656-922-4
Price: $ 69.00 (Including Shipping Charge, Cost of
Book and Other expenses)
Enjoy Reading!!
Regards,
Tarun Tyagi
J-110, Patel Nagar - 1,
Ghaziabad (U.P.), India -201001
Cell: (+91)9868337762
http://www.DataDoctor.BizYour page doesn't render at all in Firefox. You might want to check that
out.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Author Tarun Tyagi" <tyagi_st@.yahoo.com> wrote in message
news:a921f5f5.0412010120.1b976a90@.posting.google.com...
> Hi!
> I am glad to introduce World's First Book on Professional Data
> Recovery Programming. Book also Includes a FREE CD, which contains
> complete Source Codes of all the software/Programs described within
> the book and may interesting tools
> You can see the contents of the book and order Online on following
> link:
> http://www.DataDoctor.biz/author.htm
> The Details of the Book are as follows:
> Title of the book: "Data Recovery with & without Programming"
> Author of the book: Tarun Tyagi
> Publishers of the book: BPB Publications, New Delhi, India
> Number of Pages: 540
> Size: (9.5 x 7.5 x 1.0) Inches
> ISBN: 81-7656-922-4
> Price: $ 69.00 (Including Shipping Charge, Cost of
> Book and Other expenses)
> Enjoy Reading!!
> Regards,
> Tarun Tyagi
> J-110, Patel Nagar - 1,
> Ghaziabad (U.P.), India -201001
> Cell: (+91)9868337762
> http://www.DataDoctor.Biz

Data Recovery Book

Hi!
I am glad to introduce World's First Book on Professional Data
Recovery Programming. Book also Includes a FREE CD, which contains
complete Source Codes of all the software/Programs described within
the book and may interesting tools
You can see the contents of the book and order Online on following
link:
http://www.DataDoctor.biz/author.htm
The Details of the Book are as follows:
Title of the book: "Data Recovery with & without Programming"
Author of the book: Tarun Tyagi
Publishers of the book: BPB Publications, New Delhi, India
Number of Pages: 540
Size: (9.5 x 7.5 x 1.0) Inches
ISBN: 81-7656-922-4
Price: $ 69.00 (Including Shipping Charge, Cost of
Book and Other expenses)
Enjoy Reading!!
Regards,
Tarun Tyagi
J-110, Patel Nagar - 1,
Ghaziabad (U.P.), India -201001
Cell: (+91)9868337762
http://www.DataDoctor.BizYour page doesn't render at all in Firefox. You might want to check that
out.
--
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Author Tarun Tyagi" <tyagi_st@.yahoo.com> wrote in message
news:a921f5f5.0412010120.1b976a90@.posting.google.com...
> Hi!
> I am glad to introduce World's First Book on Professional Data
> Recovery Programming. Book also Includes a FREE CD, which contains
> complete Source Codes of all the software/Programs described within
> the book and may interesting tools
> You can see the contents of the book and order Online on following
> link:
> http://www.DataDoctor.biz/author.htm
> The Details of the Book are as follows:
> Title of the book: "Data Recovery with & without Programming"
> Author of the book: Tarun Tyagi
> Publishers of the book: BPB Publications, New Delhi, India
> Number of Pages: 540
> Size: (9.5 x 7.5 x 1.0) Inches
> ISBN: 81-7656-922-4
> Price: $ 69.00 (Including Shipping Charge, Cost of
> Book and Other expenses)
> Enjoy Reading!!
> Regards,
> Tarun Tyagi
> J-110, Patel Nagar - 1,
> Ghaziabad (U.P.), India -201001
> Cell: (+91)9868337762
> http://www.DataDoctor.Biz

Sunday, March 11, 2012

Data Modeling: Type + SubTypes

Suppose I have a database that includes 5 different "types" of people, and
each person could simultaneously be of multiple types (the types don't
really matter... so pretend it has doctors, lawyers, janitors, students, and
customers).
My Question: In general, is it perfectly acceptable in a scenario like this
to have one People table for common attributes and then 5 additional "person
type-specific" tables (e.g., a Doctors table, Lawyers, Janitors, Students,
and Customers tables) that each hold type-specific attributes?
Or is there a *general* recommendation to go with 5 tables total and
duplicate the common attributes amongst the tables.
Please understand my objective is to come up with a solid relational
database design - NOT simply to emulate the object-oriented programming
concept of inheritance in my database; and yes, I do understand the issues
related to choice of primary key (my plan is to use an IDENTITY property to
glue the People table with the various "person type" tables, and then have a
UNIQUE constraint on the "real" natural keys per "person type").
Thanks!"Jefffff" <A@.B.COM> wrote in message
news:edGY0teUGHA.2704@.tk2msftngp13.phx.gbl...
> Suppose I have a database that includes 5 different "types" of people, and
> each person could simultaneously be of multiple types (the types don't
> really matter... so pretend it has doctors, lawyers, janitors, students,
> and customers).
> My Question: In general, is it perfectly acceptable in a scenario like
> this to have one People table for common attributes and then 5 additional
> "person type-specific" tables (e.g., a Doctors table, Lawyers, Janitors,
> Students, and Customers tables) that each hold type-specific attributes?
> Or is there a *general* recommendation to go with 5 tables total and
> duplicate the common attributes amongst the tables.
> Please understand my objective is to come up with a solid relational
> database design - NOT simply to emulate the object-oriented programming
> concept of inheritance in my database; and yes, I do understand the issues
> related to choice of primary key (my plan is to use an IDENTITY property
> to glue the People table with the various "person type" tables, and then
> have a UNIQUE constraint on the "real" natural keys per "person type").
> Thanks!
>
>
Your first suggestion is better. The following article explains how and why
tables should not duplicate each other (more precisely, their predicates
should not overlap):
http://www.dbdebunk.com/page/page/622331.htm
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Why do I find that amusing :)
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:%23CQjX2eUGHA.1564@.TK2MSFTNGP11.phx.gbl...
> http://www.dbdebunk.com|||Think about it this way and it might be clearer:
People are people and have attributes that describe them as a person (Name,
DOB, etc)
People can play different roles such as Doctor, Lawyer, etc
So, you would likely have a table named Person to store those attributes
that are about the person
Then, seperate tables for each role the person may play
"Jefffff" <A@.B.COM> wrote in message
news:edGY0teUGHA.2704@.tk2msftngp13.phx.gbl...
> Suppose I have a database that includes 5 different "types" of people, and
> each person could simultaneously be of multiple types (the types don't
> really matter... so pretend it has doctors, lawyers, janitors, students,
> and customers).
> My Question: In general, is it perfectly acceptable in a scenario like
> this to have one People table for common attributes and then 5 additional
> "person type-specific" tables (e.g., a Doctors table, Lawyers, Janitors,
> Students, and Customers tables) that each hold type-specific attributes?
> Or is there a *general* recommendation to go with 5 tables total and
> duplicate the common attributes amongst the tables.
> Please understand my objective is to come up with a solid relational
> database design - NOT simply to emulate the object-oriented programming
> concept of inheritance in my database; and yes, I do understand the issues
> related to choice of primary key (my plan is to use an IDENTITY property
> to glue the People table with the various "person type" tables, and then
> have a UNIQUE constraint on the "real" natural keys per "person type").
> Thanks!
>
>

Thursday, March 8, 2012

Data Model Relationships

I am trying to create a data source view that includes a Fact table and
several related dimension tables. One of my dimension tables is quite small
and uses a tinyint PK. For some reason when I bring this table into the
model it thinks the PK is a System.Int32 datatype and won't allow a
relationship to the fact table FK which it sees as a System.Byte datatype.
In the database both fields are tinyint datatypes and there is a
relationship between the two.
My question is: Do I have to increase the field to a smallint in order to
create a relationship in the model or is there a workaround. This is my
first attempt at creating a data model for the Report Builder and any tips
would be appreciated. Thanks.I've noticed that if a key is an IDENTITY field then, regardless, it is seen
as an Int32. The behavior seems consistent in reporting services and in
analysis services. What we've decided to do is to make all primary and
foreign keys standard Ints (Int32) instead of tiny and small ints - even when
the smaller values were appropriate. The other thing you could do is to make
the table a named query and cast the key as a smaller int so the relationship
works.
"Elmer Miller" wrote:
> I am trying to create a data source view that includes a Fact table and
> several related dimension tables. One of my dimension tables is quite small
> and uses a tinyint PK. For some reason when I bring this table into the
> model it thinks the PK is a System.Int32 datatype and won't allow a
> relationship to the fact table FK which it sees as a System.Byte datatype.
> In the database both fields are tinyint datatypes and there is a
> relationship between the two.
> My question is: Do I have to increase the field to a smallint in order to
> create a relationship in the model or is there a workaround. This is my
> first attempt at creating a data model for the Report Builder and any tips
> would be appreciated. Thanks.
>
>|||sounds correct to me.
I had an identity on a TinyInt and I think that it just blatantly
friggin crashed SSAS or something ridiculous
-Aaron
Aaron wrote:
> I've noticed that if a key is an IDENTITY field then, regardless, it is seen
> as an Int32. The behavior seems consistent in reporting services and in
> analysis services. What we've decided to do is to make all primary and
> foreign keys standard Ints (Int32) instead of tiny and small ints - even when
> the smaller values were appropriate. The other thing you could do is to make
> the table a named query and cast the key as a smaller int so the relationship
> works.
> "Elmer Miller" wrote:
> > I am trying to create a data source view that includes a Fact table and
> > several related dimension tables. One of my dimension tables is quite small
> > and uses a tinyint PK. For some reason when I bring this table into the
> > model it thinks the PK is a System.Int32 datatype and won't allow a
> > relationship to the fact table FK which it sees as a System.Byte datatype.
> > In the database both fields are tinyint datatypes and there is a
> > relationship between the two.
> > My question is: Do I have to increase the field to a smallint in order to
> > create a relationship in the model or is there a workaround. This is my
> > first attempt at creating a data model for the Report Builder and any tips
> > would be appreciated. Thanks.
> >
> >
> >

Friday, February 17, 2012

Data from two tables

I am developing a system that tracks phonecall usage. I have an sql server db that includes two tables which include (amongst others) the fields below them:

phone_emp_mast (contains user info.)
-------
Account_Code
First_Name
Last_Name
Department

detail (contains info on individual calls)
---
Account_Code
Duration

I want to write a query that returns the account_code, first_name, last_name, no. of calls made, avg. length of call, max. length of call and total minutes of calls for each employee in a given department

I tried the following query:

SELECT d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME, COUNT(*) AS NoOfCalls, AVG(d.DURATION) AS AverageLength, MAX(d.DURATION) AS MaxCall, SUM(d.DURATION) AS TotalMins

FROM DETAIL d CROSS JOIN
PHONE_EMP_MAST p

WHERE (d.ACCOUNT_CODE = d.ACCOUNT_CODE) AND (p.DEPARTMENT = 'deptname')
GROUP BY d.ACCOUNT_CODE;

and it keeps returning the error message:
Column p.last_name is invalid in the select list because it is not contained in either an aggregate function or the group by clause

Can anyone figure out a better way of doing this? please?The GROUP BY clause has to specify every column that was not aggregated in the SELECT clause - irritatingly!

SELECT d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME, COUNT(*) AS NoOfCalls, AVG(d.DURATION) AS AverageLength, MAX(d.DURATION) AS MaxCall, SUM(d.DURATION) AS TotalMins

FROM DETAIL d CROSS JOIN
PHONE_EMP_MAST p

WHERE (d.ACCOUNT_CODE = d.ACCOUNT_CODE) AND (p.DEPARTMENT = 'deptname')
GROUP BY d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME;|||Thanks for that, I have used the following select statement and it is working perfectly. However I now have a new problem...

SELECT d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME, COUNT(*) AS NoOfCalls, AVG(d.DURATION) AS AverageLength, MAX(d.DURATION) AS MaxCall,
SUM(d.DURATION) AS TotalMins
FROM DETAIL d INNER JOIN
PHONE_EMP_MAST p ON d.ACCOUNT_CODE = p.ACCOUNT_CODE
WHERE (p.DEPARTMENT = 'deptname')
GROUP BY d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME
ORDER BY p.LAST_NAME;

I now need to get a count of the number of fields in the detail table where the duration is less than a minute... can anyone suggest a way of doing this. I tried putting in the bits between the stars

SELECT d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME, COUNT(*) AS NoOfCalls, AVG(d.DURATION) AS AverageLength, MAX(d.DURATION) AS MaxCall,
SUM(d.DURATION) AS TotalMins,
***(SELECT COUNT(d.DURATION)
WHERE duration < 1) AS NoOfCallsLessThan1***
FROM DETAIL d INNER JOIN
PHONE_EMP_MAST p ON d.ACCOUNT_CODE = p.ACCOUNT_CODE
WHERE (p.DEPARTMENT = 'operations admin')
GROUP BY d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME, ***d.DURATION, p.ACCOUNT_CODE***
ORDER BY p.LAST_NAME

but when I do this it returns all the calls individually since instead of only returning 1 row for each account code... anyone have any suggestions or is there anything you don't understand about my explanation?

Thanks in advance!|||You need to add a CASE (or DECODE if using Oracle pre-9i) expression in your first query:

SELECT d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME, COUNT(*) AS NoOfCalls, AVG(d.DURATION) AS AverageLength, MAX(d.DURATION) AS MaxCall,
SUM(d.DURATION) AS TotalMins,
SUM( CASE WHEN d.duration < 1 THEN 1 ELSE 0 END ) shortcalls
FROM DETAIL d INNER JOIN
PHONE_EMP_MAST p ON d.ACCOUNT_CODE = p.ACCOUNT_CODE
WHERE (p.DEPARTMENT = 'deptname')
GROUP BY d.ACCOUNT_CODE, p.LAST_NAME, p.FIRST_NAME
ORDER BY p.LAST_NAME;

The DECODE version would be:

SUM( DECODE( SIGN( d.duration-1), -1, 1, 0 ) ) shortcalls|||I'm actually using SQL server... do you know if SQL server supports this function?|||Originally posted by kieranodwyer
I'm actually using SQL server... do you know if SQL server supports this function?
Not DECODE - that's Oracle's own, but CASE is ANSI standard so I imagine that at least the latest version of SQL Server supports it.|||Thanks alot Tony... Thats working perfectly!