Showing posts with label sales. Show all posts
Showing posts with label sales. Show all posts

Wednesday, March 21, 2012

Newbie Query Problem

I want to use the same field in one table and return multiple columns for
different criteria. In other words...
First column
SUM(Sales.NetSales) as 'Total Sales').
Then I want a second column as
SUM(Sales.NetSales) as 'Category 02' where Sales.categoryid='02'.
Is this reasonable? I am sure that it is a simple thing that I am just
ignorant of.
Thanks.
ChuckChuck,
Try:
--rows
SELECT CategoryID, SUM(Sales) AS 'Total Sales'
FROM NetSales
GROUP BY CategoryID
--or
--columns
SELECT 'Category 1' = (SELECT SUM(Sales) AS 'Total Sales'FROM NetSales WHERE
CategoryID = 1),
'Category 2' = (SELECT SUM(Sales) AS 'Total Sales'FROM NetSales WHERE
CategoryID = 2)
HTH
Jerry
"Chuck" <Chuck@.discussions.microsoft.com> wrote in message
news:94FD5CDE-C7BE-43CF-857C-2A847675A1EF@.microsoft.com...
>I want to use the same field in one table and return multiple columns for
> different criteria. In other words...
> First column
> SUM(Sales.NetSales) as 'Total Sales').
> Then I want a second column as
> SUM(Sales.NetSales) as 'Category 02' where Sales.categoryid='02'.
> Is this reasonable? I am sure that it is a simple thing that I am just
> ignorant of.
> Thanks.
> Chuck|||SELECT
(SELECT SUM(NetSales) FROM Sales) as TotalSales,
(SELECT SUM(NetSales) FROM Sales WHERE categoryid = '02') as Category02
Chuck wrote:
> I want to use the same field in one table and return multiple columns for
> different criteria. In other words...
> First column
> SUM(Sales.NetSales) as 'Total Sales').
> Then I want a second column as
> SUM(Sales.NetSales) as 'Category 02' where Sales.categoryid='02'.
> Is this reasonable? I am sure that it is a simple thing that I am just
> ignorant of.
> Thanks.
> Chuck|||On Mon, 19 Sep 2005 11:58:06 -0700, Chuck wrote:

>I want to use the same field in one table and return multiple columns for
>different criteria. In other words...
>First column
>SUM(Sales.NetSales) as 'Total Sales').
>Then I want a second column as
>SUM(Sales.NetSales) as 'Category 02' where Sales.categoryid='02'.
>Is this reasonable? I am sure that it is a simple thing that I am just
>ignorant of.
>Thanks.
>Chuck
Hi Chuck,
Here's a way that requires only one pass over the table:
SELECT SUM(NetSales) AS 'Total Sales',
SUM(CASE WHEN categoryid = '02' THEN NetSales ELSE NULL END) AS
'Category 02'
FROM YourTable
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

newbie Q

Hi, and Thanks for your thoughts!
I am evaluating a product, and the sales team presents an
option I am not familiar with.
Can a SQL/OBDC connection accross the internet be
encrypted (via or utilizing) OBDC?
Any heads-up or caveats will be appreciated.
Brent
Yes, SQL Server (and therefore the ODBC driver) supports encrypting the
connection.
Brannon
"Brent D." <anonymous@.discussions.microsoft.com> wrote in message
news:1ba901c4a0dd$452c3c40$a601280a@.phx.gbl...
> Hi, and Thanks for your thoughts!
> I am evaluating a product, and the sales team presents an
> option I am not familiar with.
> Can a SQL/OBDC connection accross the internet be
> encrypted (via or utilizing) OBDC?
> Any heads-up or caveats will be appreciated.
> Brent

Monday, March 12, 2012

Newbie Help!

I work for a company who have just lost the IT Manager, and we are in the
process of appointing another, I am a amature person (normally in sales,
don't hate me). However, we are using Sharepoint POrtal server with a SQL
2000 server for the databases.
There is the companyC1_SITE database which is now showing as suspect after a
server restart, and I notice the LDF is showing 0kb size.
The msdb.mdf is also showing as suspect.
The error log says that the SITE database was not detached cleanly.
I have a backup from the beginning of October, but nothing after that seems
to be valid. So I now must rely on whether or not it will be possible to
recover the corrupt site MDF?
The MDF's are on a RAID array with 270GB free space so the databases did not
become suspect due to space running out.
Any pointers would be very much appreciated.
P.Your best bet if you want it fixed ASAP and with the least risk of data loss
is to contact MS PSS so they can work directly with you to see what can be
done. Is your data worth about $225.00? I suspect it is and that will be a
small price to pay to get it fixed properly.
http://support.microsoft.com/default.aspx?scid=fh;EN-US;sql SQL Support
http://www.mssqlserver.com/faq/general-pss.asp MS PSS
--
Andrew J. Kelly SQL MVP
"Paul Davies" <bob@.notachance.com> wrote in message
news:_9Kud.6383$Cp4.2422@.fe1.news.blueyonder.co.uk...
>I work for a company who have just lost the IT Manager, and we are in the
>process of appointing another, I am a amature person (normally in sales,
>don't hate me). However, we are using Sharepoint POrtal server with a SQL
>2000 server for the databases.
> There is the companyC1_SITE database which is now showing as suspect after
> a server restart, and I notice the LDF is showing 0kb size.
> The msdb.mdf is also showing as suspect.
> The error log says that the SITE database was not detached cleanly.
> I have a backup from the beginning of October, but nothing after that
> seems to be valid. So I now must rely on whether or not it will be
> possible to recover the corrupt site MDF?
> The MDF's are on a RAID array with 270GB free space so the databases did
> not become suspect due to space running out.
> Any pointers would be very much appreciated.
> P.
>|||I agree with Andrew. Call the experts. They can walk you throught the
steps most likely to get your data back. Right after that phone call, find
yourself a temporary IT guy from a reputable consulting company. You will
probably have to pay extra for the emergency coverage, but if your business
depends on your systems, you really don't have a choice.
--
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:eTcXXn%233EHA.2592@.TK2MSFTNGP09.phx.gbl...
> Your best bet if you want it fixed ASAP and with the least risk of data
loss
> is to contact MS PSS so they can work directly with you to see what can be
> done. Is your data worth about $225.00? I suspect it is and that will be
a
> small price to pay to get it fixed properly.
>
> http://support.microsoft.com/default.aspx?scid=fh;EN-US;sql SQL Support
> http://www.mssqlserver.com/faq/general-pss.asp MS PSS
> --
> Andrew J. Kelly SQL MVP
>
> "Paul Davies" <bob@.notachance.com> wrote in message
> news:_9Kud.6383$Cp4.2422@.fe1.news.blueyonder.co.uk...
> >I work for a company who have just lost the IT Manager, and we are in the
> >process of appointing another, I am a amature person (normally in sales,
> >don't hate me). However, we are using Sharepoint POrtal server with a SQL
> >2000 server for the databases.
> >
> > There is the companyC1_SITE database which is now showing as suspect
after
> > a server restart, and I notice the LDF is showing 0kb size.
> >
> > The msdb.mdf is also showing as suspect.
> >
> > The error log says that the SITE database was not detached cleanly.
> >
> > I have a backup from the beginning of October, but nothing after that
> > seems to be valid. So I now must rely on whether or not it will be
> > possible to recover the corrupt site MDF?
> >
> > The MDF's are on a RAID array with 270GB free space so the databases did
> > not become suspect due to space running out.
> >
> > Any pointers would be very much appreciated.
> >
> > P.
> >
>

Friday, March 9, 2012

Newbie Design Question

I am a newbie in BI and have the following design question:

I have a scenario where I have a Sales fact table linked to a customer dimension. The customers some customers attributes might change and I would like to keep history of those attributes, such as Marital Status.
One way is to store the Marital Status as attribute in the customer dimension and enter multiple records for each customer whenever the marital status changes, but I should then add date and status fields to the customer dimension.
Another way is to store the Marital Status as a separate dimension and link it directly to the fact table. While maintaining only one record for each unique customer in the customer dimension, and in this case no Date and Status fields are needed on customer.
What is the best way of implementing this scenario? Are there any pros cons for each one, Or Maybe there is a better way of solving it?

And suppose I use the first method where multiple customer records are kept, while processing to get the sales done for people that are married, some processing should be done to only consider each customer once (Only Status is Active). This is through MDX I suppose.

I am sure this issue is typical and basic but just wanted to get some guidelines.

Appreciate your help,
Grace

Hi Grace,

These design issues are often discussed as part of the "Slowly Changing Dimension" techniques in dimensional modelling, for example in the Kimball article below. Typically these technique ensure that only the appropriate row corresponding to a dimension member is considered (one way is by using surrogate keys):

http://www.intelligententerprise.com/db_area/archives/1999/990308/warehouse.jhtml

>>

When A Slowly Changing Dimension Speeds Up
Ralph Kimball

...

>>

|||

Thanks Deepak for the guidance.

Saturday, February 25, 2012

Newbie - Query convert money

I have been unsuccessful at getting this to display the way I want it to.
BOL says that convert(money, [expression] , 1) will display my sales figures
as 1,234,567.89. However the results for my query
SELECT TOP 100 PERCENT SalespersonID, convert(money, SUM(NetSales),1)
AS NetSales
GROUP BY SalespersonID
ORDER BY SalespersonID
returns the column NetSales as 1234567.89.
This is driving my boss crazy trying to determine whether the result is
$100,000 or $1,000,000.
Can someone explain this to me? The data type is already money, so I'm
wondering if it is just ignoring the convert...
I appreciate your help!Format at the client / presentation tier, because asking SQL Server to do
this is silly:
SELECT
'$'+REVERSE(SUBSTRING(REVERSE(CONVERT(VA
RCHAR(100),CONVERT(MONEY,money_colum
n),1)),1,100))
AS money_column
FROM table
"Chuck" <Chuck@.discussions.microsoft.com> wrote in message
news:B3584EDB-D8FA-422B-8A67-D2B45735E2ED@.microsoft.com...
>I have been unsuccessful at getting this to display the way I want it to.
> BOL says that convert(money, [expression] , 1) will display my sales
> figures
> as 1,234,567.89. However the results for my query
> SELECT TOP 100 PERCENT SalespersonID, convert(money, SUM(NetSales),1)
> AS NetSales
> GROUP BY SalespersonID
> ORDER BY SalespersonID
> returns the column NetSales as 1234567.89.
> This is driving my boss crazy trying to determine whether the result is
> $100,000 or $1,000,000.
> Can someone explain this to me? The data type is already money, so I'm
> wondering if it is just ignoring the convert...
> I appreciate your help!
>