Showing posts with label order. Show all posts
Showing posts with label order. Show all posts

Sunday, March 25, 2012

@@ identity does not work ?

By standard i try my questions in SQL Mangment.

set nocount on
insert into [order]
(orderdate,deliverydate,status,Totalprice,customerID)
values(2006-02-23,2006-02-23,'N',10000,10)
(insert into temp (orderid)values(@.@.identity))

Major Error 0x80040E14, Minor Error 25569
> set nocount on
insert into [order]
(orderdate,deliverydate,status,Totalprice,customerID)
values(2006-02-23,2006-02-23,'N',10000,10)
(insert into temp (orderid)values(@.@.identity))
Invalid set option. [ Set option = nocount ]

Without Nocount:

insert into [order]
(orderdate,deliverydate,status,Totalprice,customerID)
values(2006-02-23,2006-02-23,'N',10000,10)
(insert into temp (orderid)values(@.@.identity))

Major Error 0x80040E14, Minor Error 25501
> insert into [order]
(orderdate,deliverydate,status,Totalprice,customerID)
values(2006-02-23,2006-02-23,'N',10000,10)
(insert into temp (orderid)values(@.@.identity))
There was an error parsing the query. [ Token line number = 4,Token line offset = 1,Token in error = ( ]

How do i get @.@.identity to work. I understand that @.@.identity only can be used in the sam insert session.

You can use an alternative solution to @.@.IDENTITY: retrieve the next identity value using the INFORMATION_SCHEMA.COLUMNS data. Try this command:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS

You will see all sorts of interesting info with SQL Mobile / Everywhere.

|||What is SQL everywere .. is it the same as Sql mobile or a completey other instance of Sql server ?|||

SQL Everywhere is same as SQL Mobile expect that it will be supported on Desktop as well as Devices. SQL Mobile was the compltete story for Devices, but now, with the desktop restriction removed, one can develop apps for desktop using SQL Everywhere (Earlier one needed VS2005 or ss2005 to develop app on desktop).

Also SQL Everywhere has extra features like |DataDirectory| and ClickOnce. Please let us know your specific question on this.

Sachin

Tuesday, March 20, 2012

::fn_virtualfilestats does not return any rows

Is there any pre-requirements in order to use ::fn_virtualfilestats function.
When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
always 0 rows.
Need help !!!
thanks
Hi
You have to supply the DatabaseID and FileID.
e.g.
SELECT *
FROM :: fn_virtualfilestats(1, 1)
See BOL for full information.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512B9BEB34B40@.droptable.com...
> Is there any pre-requirements in order to use ::fn_virtualfilestats
> function.
> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
> always 0 rows.
> Need help !!!
> thanks
|||Or to get all the files for all the db's you can do this:
SELECT *
FROM :: fn_virtualfilestats(-1, -1)
Andrew J. Kelly SQL MVP
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:eMd3kjkhFHA.1480@.TK2MSFTNGP10.phx.gbl...
> Hi
> You have to supply the DatabaseID and FileID.
> e.g.
> SELECT *
> FROM :: fn_virtualfilestats(1, 1)
> See BOL for full information.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "jesenko k via droptable.com" <forum@.droptable.com> wrote in message
> news:512B9BEB34B40@.droptable.com...
>
|||SELECT * FROM :: fn_virtualfilestats(-1, -1)
STILL NO ROWS
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200507/1
|||Do you have SQL perfmon counters? What do you get in the last waittype
column if you select * from sysprocesses? If it always shows misc then you
blew away your counters. This can usually be fixed by restarting sql server
and ensuring NOTHING is monitoring any sql perfmon counters at the time.
This may be helpful as well:
http://www.extremeexperts.com/SQL/FA...rCounters.aspx
Andrew J. Kelly SQL MVP
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forums...erver/200507/1
|||Probably your perf mon counters are not working.
Does select * from master.dbo.sysperfinfo return any data?
If not either your server is started with the -x option or you perfmon
counter are no longer working.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forums...erver/200507/1
|||Do you have SQL perfmon counters?
I AM ORACLE GUY. I DO NOT KNOW.
What do you get in the lastwaittype column if you select * from sysprocesses?
ONLY "MISCELLANEOUS"
This can usually be fixed by restarting sql server and ensuring NOTHING is
monitoring any sql perfmon counters at the time.
ALREADY TRIED. DOES NOT WORK
http://www.extremeexperts.com/SQL/FA...rCounters.aspx
I'LL TRY THIS. LET YOU KNOW
Does select * from master.dbo.sysperfinfo return any data?
NO DATA
If not either your server is started with the -x option or you perfmon
counter are no longer working.
IT SEEMS TO ME PERFMON COUNTER DOES NOT WORK
Thanks
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200507/1
|||i made it work reloading counters
1) unlodctr MSSQLServer
2) lodctr sqlctr.ini
3) net stop mssqlserver
4) net start mssqlserver
now it works
thanks
Message posted via http://www.droptable.com

::fn_virtualfilestats does not return any rows

Is there any pre-requirements in order to use ::fn_virtualfilestats function
.
When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
always 0 rows.
Need help !!!
thanksHi
You have to supply the DatabaseID and FileID.
e.g.
SELECT *
FROM :: fn_virtualfilestats(1, 1)
See BOL for full information.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512B9BEB34B40@.droptable.com...
> Is there any pre-requirements in order to use ::fn_virtualfilestats
> function.
> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
> always 0 rows.
> Need help !!!
> thanks|||Or to get all the files for all the db's you can do this:
SELECT *
FROM :: fn_virtualfilestats(-1, -1)
Andrew J. Kelly SQL MVP
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:eMd3kjkhFHA.1480@.TK2MSFTNGP10.phx.gbl...
> Hi
> You have to supply the DatabaseID and FileID.
> e.g.
> SELECT *
> FROM :: fn_virtualfilestats(1, 1)
> See BOL for full information.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "jesenko k via droptable.com" <forum@.droptable.com> wrote in message
> news:512B9BEB34B40@.droptable.com...
>|||SELECT * FROM :: fn_virtualfilestats(-1, -1)
STILL NO ROWS
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200507/1|||Do you have SQL perfmon counters? What do you get in the last waittype
column if you select * from sysprocesses? If it always shows misc then you
blew away your counters. This can usually be fixed by restarting sql server
and ensuring NOTHING is monitoring any sql perfmon counters at the time.
This may be helpful as well:
http://www.extremeexperts.com/SQL/F...erCounters.aspx
Andrew J. Kelly SQL MVP
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200507/1|||Probably your perf mon counters are not working.
Does select * from master.dbo.sysperfinfo return any data?
If not either your server is started with the -x option or you perfmon
counter are no longer working.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"jesenko k via droptable.com" <forum@.droptable.com> wrote in message
news:512CA670C3120@.droptable.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200507/1|||Do you have SQL perfmon counters?
I AM ORACLE GUY. I DO NOT KNOW.
What do you get in the lastwaittype column if you select * from sysprocesses
?
ONLY "MISCELLANEOUS"
This can usually be fixed by restarting sql server and ensuring NOTHING is
monitoring any sql perfmon counters at the time.
ALREADY TRIED. DOES NOT WORK
http://www.extremeexperts.com/SQL/F...erCounters.aspx
I'LL TRY THIS. LET YOU KNOW
Does select * from master.dbo.sysperfinfo return any data?
NO DATA
If not either your server is started with the -x option or you perfmon
counter are no longer working.
IT SEEMS TO ME PERFMON COUNTER DOES NOT WORK
Thanks
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200507/1|||i made it work reloading counters
1) unlodctr MSSQLServer
2) lodctr sqlctr.ini
3) net stop mssqlserver
4) net start mssqlserver
now it works
thanks
Message posted via http://www.droptable.comsql

::fn_virtualfilestats does not return any rows

Is there any pre-requirements in order to use ::fn_virtualfilestats function.
When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
always 0 rows.
Need help !!!
thanksHi
You have to supply the DatabaseID and FileID.
e.g.
SELECT *
FROM :: fn_virtualfilestats(1, 1)
See BOL for full information.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:512B9BEB34B40@.SQLMonster.com...
> Is there any pre-requirements in order to use ::fn_virtualfilestats
> function.
> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
> always 0 rows.
> Need help !!!
> thanks|||Or to get all the files for all the db's you can do this:
SELECT *
FROM :: fn_virtualfilestats(-1, -1)
--
Andrew J. Kelly SQL MVP
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:eMd3kjkhFHA.1480@.TK2MSFTNGP10.phx.gbl...
> Hi
> You have to supply the DatabaseID and FileID.
> e.g.
> SELECT *
> FROM :: fn_virtualfilestats(1, 1)
> See BOL for full information.
> --
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
> news:512B9BEB34B40@.SQLMonster.com...
>> Is there any pre-requirements in order to use ::fn_virtualfilestats
>> function.
>> When i ran "select * from ::fn_virtualfilestats" in SQLServer2000 returns
>> always 0 rows.
>> Need help !!!
>> thanks
>|||SELECT * FROM :: fn_virtualfilestats(-1, -1)
STILL NO ROWS
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||Do you have SQL perfmon counters? What do you get in the last waittype
column if you select * from sysprocesses? If it always shows misc then you
blew away your counters. This can usually be fixed by restarting sql server
and ensuring NOTHING is monitoring any sql perfmon counters at the time.
This may be helpful as well:
http://www.extremeexperts.com/SQL/FAQ/EnablingPerCounters.aspx
Andrew J. Kelly SQL MVP
"jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:512CA670C3120@.SQLMonster.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||Probably your perf mon counters are not working.
Does select * from master.dbo.sysperfinfo return any data?
If not either your server is started with the -x option or you perfmon
counter are no longer working.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright © SQLDev.Net 1991-2005 All rights reserved.
"jesenko k via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:512CA670C3120@.SQLMonster.com...
> SELECT * FROM :: fn_virtualfilestats(-1, -1)
> STILL NO ROWS
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||Do you have SQL perfmon counters?
I AM ORACLE GUY. I DO NOT KNOW.
What do you get in the lastwaittype column if you select * from sysprocesses?
ONLY "MISCELLANEOUS"
This can usually be fixed by restarting sql server and ensuring NOTHING is
monitoring any sql perfmon counters at the time.
ALREADY TRIED. DOES NOT WORK
http://www.extremeexperts.com/SQL/FAQ/EnablingPerCounters.aspx
I'LL TRY THIS. LET YOU KNOW
Does select * from master.dbo.sysperfinfo return any data?
NO DATA
If not either your server is started with the -x option or you perfmon
counter are no longer working.
IT SEEMS TO ME PERFMON COUNTER DOES NOT WORK
Thanks
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200507/1|||i made it work reloading counters
1) unlodctr MSSQLServer
2) lodctr sqlctr.ini
3) net stop mssqlserver
4) net start mssqlserver
now it works
thanks
Message posted via http://www.sqlmonster.com

Saturday, February 25, 2012

.NET 1.1 running on SQL Server 2005

Hi, I am migrating my client's site from SQL 2k to 2005. The site was built on .NET 1.1

In order to run SQL 2005, do we need to upgrade to .NET 2.0 in order to run the site?

If we do need to upgrade to .net 2.0, is there any way to get around the problem and run it on .NET 1.1. This is because we have a lot of 3rd party componenet which only support .NET 1.1

Thanks in advance.

Paul

No.|||You would need the 2.0 framework for sure. I think the SQL 2005 installation wizard would detect and install the framework for you.You dont need to upgrade your application to VS 2005, however.

Monday, February 13, 2012

*** Urgent help please ...

Can someone please help me resolve the following -
I have a table consisting of sales orders information with salesmen who lead
the order.
Now I have a need to find average by adding individual salesman's records
and then dividing it by total no. of salesmen in the table.
Ex. Saleman No., Order No.
1, 1
1, 2
2,3
1,4
3,5
3,6
In this case the output should be something like
Salesman #orders
1 3
2 1
3 2
Average = #total no. of orders / #total no. of salesmen
my query is -
select firstname, lastname, count(*) from project
where
ISNULL(CompleteFLAG,'N') ='N' )
group by firstname, lastname
order by firstname
I would like to get the average by adding count(*) for each person/#total
no. of persons.
Thank you,
-Me
Try something like this.
select distinct(Saleman No),count(Order No) as OrderNo from vendor
group by Saleman No
Maninder
MCDBA
|||On 13 Feb, 16:09, Me <M...@.discussions.microsoft.com> wrote:
> Can someone please help me resolve the following -
> I have a table consisting of sales orders information with salesmen who lead
> the order.
> Now I have a need to find average by adding individual salesman's records
> and then dividing it by total no. of salesmen in the table.
> Ex. Saleman No., Order No.
> 1, 1
> 1, 2
> 2,3
> 1,4
> 3,5
> 3,6
> In this case the output should be something like
> Salesman #orders
> 1 3
> 2 1
> 3 2
> Average = #total no. of orders / #total no. of salesmen
> my query is -
> select firstname, lastname, count(*) from project
> where
> ISNULL(CompleteFLAG,'N') ='N' )
> group by firstname, lastname
> order by firstname
> I would like to get the average by adding count(*) for each person/#total
> no. of persons.
> Thank you,
> -Me
It seems like your query contradicts the sample data you used. What is
the key of the Project table? Do you really store the sales person's
name next to each order? Does every order have a sales person
associated with it? Please always include DDL so that we don't have to
guess these things.
Perhaps there are sales people who haven't yet got any orders to their
names? In that case you'll need a SalesPerson table (which I would
hope you have in any case). Here's one possibility:
SELECT COUNT(*)
/(SELECT CAST(COUNT(*) AS REAL) FROM SalesPerson) AS AvgSales
FROM Project;
If you just want to include those who have sales, try:
SELECT COUNT(*)
/(SELECT CAST(COUNT(DISTINCT SalesPersonNo) AS REAL)
FROM Project) AS AvgSales
FROM Project;
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
|||Hi David,
Thanks for the reply!
Your solution helped me resolve my issue.
Appreciate your help!
-Me
"David Portas" wrote:

> On 13 Feb, 16:09, Me <M...@.discussions.microsoft.com> wrote:
> It seems like your query contradicts the sample data you used. What is
> the key of the Project table? Do you really store the sales person's
> name next to each order? Does every order have a sales person
> associated with it? Please always include DDL so that we don't have to
> guess these things.
> Perhaps there are sales people who haven't yet got any orders to their
> names? In that case you'll need a SalesPerson table (which I would
> hope you have in any case). Here's one possibility:
> SELECT COUNT(*)
> /(SELECT CAST(COUNT(*) AS REAL) FROM SalesPerson) AS AvgSales
> FROM Project;
> If you just want to include those who have sales, try:
> SELECT COUNT(*)
> /(SELECT CAST(COUNT(DISTINCT SalesPersonNo) AS REAL)
> FROM Project) AS AvgSales
> FROM Project;
> --
> 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
> --
>
>
>
>
|||Hi Maninder,
Thanks for the reply!
Actually I was looking for what David has in his thread.
But appreciate your keeping my tempo going.
Thank you again for your help!
-Me
"Maninder" wrote:

> Try something like this.
> select distinct(Saleman No),count(Order No) as OrderNo from vendor
> group by Saleman No
> Maninder
> MCDBA
>

*** Urgent help please ...

Can someone please help me resolve the following -
I have a table consisting of sales orders information with salesmen who lead
the order.
Now I have a need to find average by adding individual salesman's records
and then dividing it by total no. of salesmen in the table.
Ex. Saleman No., Order No.
1, 1
1, 2
2,3
1,4
3,5
3,6
In this case the output should be something like
Salesman #orders
1 3
2 1
3 2
Average = #total no. of orders / #total no. of salesmen
my query is -
select firstname, lastname, count(*) from project
where
ISNULL(CompleteFLAG,'N') ='N' )
group by firstname, lastname
order by firstname
I would like to get the average by adding count(*) for each person/#total
no. of persons.
Thank you,
-MeTry something like this.
select distinct(Saleman No),count(Order No) as OrderNo from vendor
group by Saleman No
Maninder
MCDBA|||On 13 Feb, 16:09, Me <M...@.discussions.microsoft.com> wrote:
> Can someone please help me resolve the following -
> I have a table consisting of sales orders information with salesmen who le
ad
> the order.
> Now I have a need to find average by adding individual salesman's records
> and then dividing it by total no. of salesmen in the table.
> Ex. Saleman No., Order No.
> 1, 1
> 1, 2
> 2,3
> 1,4
> 3,5
> 3,6
> In this case the output should be something like
> Salesman #orders
> 1 3
> 2 1
> 3 2
> Average = #total no. of orders / #total no. of salesmen
> my query is -
> select firstname, lastname, count(*) from project
> where
> ISNULL(CompleteFLAG,'N') ='N' )
> group by firstname, lastname
> order by firstname
> I would like to get the average by adding count(*) for each person/#total
> no. of persons.
> Thank you,
> -Me
It seems like your query contradicts the sample data you used. What is
the key of the Project table? Do you really store the sales person's
name next to each order? Does every order have a sales person
associated with it? Please always include DDL so that we don't have to
guess these things.
Perhaps there are sales people who haven't yet got any orders to their
names? In that case you'll need a SalesPerson table (which I would
hope you have in any case). Here's one possibility:
SELECT COUNT(*)
/(SELECT CAST(COUNT(*) AS REAL) FROM SalesPerson) AS AvgSales
FROM Project;
If you just want to include those who have sales, try:
SELECT COUNT(*)
/(SELECT CAST(COUNT(DISTINCT SalesPersonNo) AS REAL)
FROM Project) AS AvgSales
FROM Project;
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
--|||Hi David,
Thanks for the reply!
Your solution helped me resolve my issue.
Appreciate your help!
-Me
"David Portas" wrote:

> On 13 Feb, 16:09, Me <M...@.discussions.microsoft.com> wrote:
> It seems like your query contradicts the sample data you used. What is
> the key of the Project table? Do you really store the sales person's
> name next to each order? Does every order have a sales person
> associated with it? Please always include DDL so that we don't have to
> guess these things.
> Perhaps there are sales people who haven't yet got any orders to their
> names? In that case you'll need a SalesPerson table (which I would
> hope you have in any case). Here's one possibility:
> SELECT COUNT(*)
> /(SELECT CAST(COUNT(*) AS REAL) FROM SalesPerson) AS AvgSales
> FROM Project;
> If you just want to include those who have sales, try:
> SELECT COUNT(*)
> /(SELECT CAST(COUNT(DISTINCT SalesPersonNo) AS REAL)
> FROM Project) AS AvgSales
> FROM Project;
> --
> 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
> --
>
>
>
>|||Hi Maninder,
Thanks for the reply!
Actually I was looking for what David has in his thread.
But appreciate your keeping my tempo going.
Thank you again for your help!
-Me
"Maninder" wrote:

> Try something like this.
> select distinct(Saleman No),count(Order No) as OrderNo from vendor
> group by Saleman No
> Maninder
> MCDBA
>

*** Urgent help please ...

Can someone please help me resolve the following -
I have a table consisting of sales orders information with salesmen who lead
the order.
Now I have a need to find average by adding individual salesman's records
and then dividing it by total no. of salesmen in the table.
Ex. Saleman No., Order No.
1, 1
1, 2
2,3
1,4
3,5
3,6
In this case the output should be something like
Salesman #orders
1 3
2 1
3 2
Average = #total no. of orders / #total no. of salesmen
my query is -
select firstname, lastname, count(*) from project
where
ISNULL(CompleteFLAG,'N') ='N' )
group by firstname, lastname
order by firstname
I would like to get the average by adding count(*) for each person/#total
no. of persons.
Thank you,
-MeTry something like this.
select distinct(Saleman No),count(Order No) as OrderNo from vendor
group by Saleman No
Maninder
MCDBA|||On 13 Feb, 16:09, Me <M...@.discussions.microsoft.com> wrote:
> Can someone please help me resolve the following -
> I have a table consisting of sales orders information with salesmen who lead
> the order.
> Now I have a need to find average by adding individual salesman's records
> and then dividing it by total no. of salesmen in the table.
> Ex. Saleman No., Order No.
> 1, 1
> 1, 2
> 2,3
> 1,4
> 3,5
> 3,6
> In this case the output should be something like
> Salesman #orders
> 1 3
> 2 1
> 3 2
> Average = #total no. of orders / #total no. of salesmen
> my query is -
> select firstname, lastname, count(*) from project
> where
> ISNULL(CompleteFLAG,'N') ='N' )
> group by firstname, lastname
> order by firstname
> I would like to get the average by adding count(*) for each person/#total
> no. of persons.
> Thank you,
> -Me
It seems like your query contradicts the sample data you used. What is
the key of the Project table? Do you really store the sales person's
name next to each order? Does every order have a sales person
associated with it? Please always include DDL so that we don't have to
guess these things.
Perhaps there are sales people who haven't yet got any orders to their
names? In that case you'll need a SalesPerson table (which I would
hope you have in any case). Here's one possibility:
SELECT COUNT(*)
/(SELECT CAST(COUNT(*) AS REAL) FROM SalesPerson) AS AvgSales
FROM Project;
If you just want to include those who have sales, try:
SELECT COUNT(*)
/(SELECT CAST(COUNT(DISTINCT SalesPersonNo) AS REAL)
FROM Project) AS AvgSales
FROM Project;
--
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
--|||Hi David,
Thanks for the reply!
Your solution helped me resolve my issue.
Appreciate your help!
-Me
"David Portas" wrote:
> On 13 Feb, 16:09, Me <M...@.discussions.microsoft.com> wrote:
> > Can someone please help me resolve the following -
> >
> > I have a table consisting of sales orders information with salesmen who lead
> > the order.
> >
> > Now I have a need to find average by adding individual salesman's records
> > and then dividing it by total no. of salesmen in the table.
> >
> > Ex. Saleman No., Order No.
> > 1, 1
> > 1, 2
> > 2,3
> > 1,4
> > 3,5
> > 3,6
> >
> > In this case the output should be something like
> >
> > Salesman #orders
> > 1 3
> > 2 1
> > 3 2
> >
> > Average = #total no. of orders / #total no. of salesmen
> >
> > my query is -
> >
> > select firstname, lastname, count(*) from project
> > where
> > ISNULL(CompleteFLAG,'N') ='N' )
> > group by firstname, lastname
> > order by firstname
> >
> > I would like to get the average by adding count(*) for each person/#total
> > no. of persons.
> >
> > Thank you,
> > -Me
> It seems like your query contradicts the sample data you used. What is
> the key of the Project table? Do you really store the sales person's
> name next to each order? Does every order have a sales person
> associated with it? Please always include DDL so that we don't have to
> guess these things.
> Perhaps there are sales people who haven't yet got any orders to their
> names? In that case you'll need a SalesPerson table (which I would
> hope you have in any case). Here's one possibility:
> SELECT COUNT(*)
> /(SELECT CAST(COUNT(*) AS REAL) FROM SalesPerson) AS AvgSales
> FROM Project;
> If you just want to include those who have sales, try:
> SELECT COUNT(*)
> /(SELECT CAST(COUNT(DISTINCT SalesPersonNo) AS REAL)
> FROM Project) AS AvgSales
> FROM Project;
> --
> 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
> --
>
>
>
>|||Hi Maninder,
Thanks for the reply!
Actually I was looking for what David has in his thread.
But appreciate your keeping my tempo going.
Thank you again for your help!
-Me
"Maninder" wrote:
> Try something like this.
> select distinct(Saleman No),count(Order No) as OrderNo from vendor
> group by Saleman No
> Maninder
> MCDBA
>