Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Sunday, March 11, 2012

Getting only multiple records for all customers

Hi,

How can I get desired data results from Sample Data given using SQL statement? Preferably without using Cursors and simple as possible.

Sample Data:

OrderID CustomerID ProductID
2 2 2
3 3 null
4 3 2
5 2 2
6 4 3
7 5 4
8 2 10
11 3 5
13 5 8
14 6 9

Desired Results:

OrderID CustomerID ProductID
2 2 2
4 3 2
5 2 2
7 5 4
8 2 10
11 3 5
13 5 8

It is not easy to 'guess' what criteria you have used.

Obviously, eliminating OrderID 3 is because nothing was ordered.

But why have OrderIDs 6 and 14 been left out?

|||

The following query will work for You..(multiple records for all customers - customers who have multiple records)

Select * from Orders Where
CustomerId in (Select CustomerId from Orders Group By CustomerId Having Count(ProductID) > 1)
and ProductId is NOT NULL

|||

Thanks for reply, Arnie.

Thanks for the answer, ManiD.

[Query] Help

Hello,
We someone be so kind to help me out with a (probably simpel) query?
This is some stripped down sample data to illustrate:
(two fields, 1 NAME & 1 NAMEDATE)
bill 01/03/2005 06:25
eric 01/03/2005 07:25
pat 01/03/2005 07:25
eric 01/03/2005 09:25
eric 01/03/2005 10:25
bill 01/03/2005 09:25
pat 01/03/2005 06:25
pat 01/03/2005 08:25
eric 01/03/2005 09:25
bill 01/03/2005 09:25
I am trying to find the count of names per hour period and I am struggling a
bit. I tried with function 'datepart(hour, NAMEDATE)' but don't get it to
work.
The query should in a query result row ...
NAME 6hr 7hr 8hr 9hr 10hr
billl 1 2
eric 1 2 1
etc
So for 'bill' there are 3 records, 1 where hour=06 and 2 where hour=9.
Eric 4 records, 1 where hour=07; 2 where hour=09 and 1 where hour=10.
Sorry if my question & layout is a bit blurry ;)
Rgds,
T.
Try,
use northwind
go
create table t (
colA varchar(25),
colB datetime
)
go
insert into t values('bill', '1/03/2005 06:25')
insert into t values('eric', '01/03/2005 07:25')
insert into t values('pat', '01/03/2005 07:25')
insert into t values('eric', '01/03/2005 09:25')
insert into t values('eric', '01/03/2005 10:25')
insert into t values('bill', '01/03/2005 09:25')
insert into t values('pat', '01/03/2005 06:25')
insert into t values('pat', '01/03/2005 08:25')
insert into t values('eric', '01/03/2005 09:25')
insert into t values('bill', '01/03/2005 09:25')
go
select
colA,
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 6 then
1 end) as [6hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 7 then
1 end) as [7hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 8 then
1 end) as [8hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 9 then
1 end) as [9hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 10 then
1 end) as [10hr]
from
t
group by
colA
order by
colA
drop table t
go
AMB
"TieTo" wrote:

> Hello,
> We someone be so kind to help me out with a (probably simpel) query?
> This is some stripped down sample data to illustrate:
> (two fields, 1 NAME & 1 NAMEDATE)
>
> bill 01/03/2005 06:25
> eric 01/03/2005 07:25
> pat 01/03/2005 07:25
> eric 01/03/2005 09:25
> eric 01/03/2005 10:25
> bill 01/03/2005 09:25
> pat 01/03/2005 06:25
> pat 01/03/2005 08:25
> eric 01/03/2005 09:25
> bill 01/03/2005 09:25
> I am trying to find the count of names per hour period and I am struggling a
> bit. I tried with function 'datepart(hour, NAMEDATE)' but don't get it to
> work.
> The query should in a query result row ...
> NAME 6hr 7hr 8hr 9hr 10hr
> billl 1 2
> eric 1 2 1
> etc
> So for 'bill' there are 3 records, 1 where hour=06 and 2 where hour=9.
> Eric 4 records, 1 where hour=07; 2 where hour=09 and 1 where hour=10.
> Sorry if my question & layout is a bit blurry ;)
> Rgds,
> T.
>
>
|||"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:352EE400-E233-4389-90A6-7A02101A1A91@.microsoft.com...
> Try,
> use northwind
> go
>
<cut>
Hey Alejandro,
Will try your proposed query. Thanks for the reply!!!!
Rgds,
T.

[Query] Help

Hello,
We someone be so kind to help me out with a (probably simpel) query?
This is some stripped down sample data to illustrate:
(two fields, 1 NAME & 1 NAMEDATE)
bill 01/03/2005 06:25
eric 01/03/2005 07:25
pat 01/03/2005 07:25
eric 01/03/2005 09:25
eric 01/03/2005 10:25
bill 01/03/2005 09:25
pat 01/03/2005 06:25
pat 01/03/2005 08:25
eric 01/03/2005 09:25
bill 01/03/2005 09:25
I am trying to find the count of names per hour period and I am struggling a
bit. I tried with function 'datepart(hour, NAMEDATE)' but don't get it to
work.
The query should in a query result row ...
NAME 6hr 7hr 8hr 9hr 10hr
---
billl 1 2
eric 1 2 1
etc
So for 'bill' there are 3 records, 1 where hour=06 and 2 where hour=9.
Eric 4 records, 1 where hour=07; 2 where hour=09 and 1 where hour=10.
Sorry if my question & layout is a bit blurry ;)
Rgds,
T.Try,
use northwind
go
create table t (
colA varchar(25),
colB datetime
)
go
insert into t values('bill', '1/03/2005 06:25')
insert into t values('eric', '01/03/2005 07:25')
insert into t values('pat', '01/03/2005 07:25')
insert into t values('eric', '01/03/2005 09:25')
insert into t values('eric', '01/03/2005 10:25')
insert into t values('bill', '01/03/2005 09:25')
insert into t values('pat', '01/03/2005 06:25')
insert into t values('pat', '01/03/2005 08:25')
insert into t values('eric', '01/03/2005 09:25')
insert into t values('bill', '01/03/2005 09:25')
go
select
colA,
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 6 then
1 end) as [6hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 7 then
1 end) as [7hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 8 then
1 end) as [8hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 9 then
1 end) as [9hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 10 then
1 end) as [10hr]
from
t
group by
colA
order by
colA
drop table t
go
AMB
"TieTo" wrote:

> Hello,
> We someone be so kind to help me out with a (probably simpel) query?
> This is some stripped down sample data to illustrate:
> (two fields, 1 NAME & 1 NAMEDATE)
>
> bill 01/03/2005 06:25
> eric 01/03/2005 07:25
> pat 01/03/2005 07:25
> eric 01/03/2005 09:25
> eric 01/03/2005 10:25
> bill 01/03/2005 09:25
> pat 01/03/2005 06:25
> pat 01/03/2005 08:25
> eric 01/03/2005 09:25
> bill 01/03/2005 09:25
> I am trying to find the count of names per hour period and I am struggling
a
> bit. I tried with function 'datepart(hour, NAMEDATE)' but don't get it to
> work.
> The query should in a query result row ...
> NAME 6hr 7hr 8hr 9hr 10hr
> ---
> billl 1 2
> eric 1 2 1
> etc
> So for 'bill' there are 3 records, 1 where hour=06 and 2 where hour=9.
> Eric 4 records, 1 where hour=07; 2 where hour=09 and 1 where hour=10.
> Sorry if my question & layout is a bit blurry ;)
> Rgds,
> T.
>
>|||"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:352EE400-E233-4389-90A6-7A02101A1A91@.microsoft.com...
> Try,
> use northwind
> go
>
<cut>
Hey Alejandro,
Will try your proposed query. Thanks for the reply!!!!
Rgds,
T.

[Query] Help

Hello,
We someone be so kind to help me out with a (probably simpel) query?
This is some stripped down sample data to illustrate:
(two fields, 1 NAME & 1 NAMEDATE)
bill 01/03/2005 06:25
eric 01/03/2005 07:25
pat 01/03/2005 07:25
eric 01/03/2005 09:25
eric 01/03/2005 10:25
bill 01/03/2005 09:25
pat 01/03/2005 06:25
pat 01/03/2005 08:25
eric 01/03/2005 09:25
bill 01/03/2005 09:25
I am trying to find the count of names per hour period and I am struggling a
bit. I tried with function 'datepart(hour, NAMEDATE)' but don't get it to
work.
The query should in a query result row ...
NAME 6hr 7hr 8hr 9hr 10hr
---
billl 1 2
eric 1 2 1
etc
So for 'bill' there are 3 records, 1 where hour=06 and 2 where hour=9.
Eric 4 records, 1 where hour=07; 2 where hour=09 and 1 where hour=10.
Sorry if my question & layout is a bit blurry ;)
Rgds,
T.Try,
use northwind
go
create table t (
colA varchar(25),
colB datetime
)
go
insert into t values('bill', '1/03/2005 06:25')
insert into t values('eric', '01/03/2005 07:25')
insert into t values('pat', '01/03/2005 07:25')
insert into t values('eric', '01/03/2005 09:25')
insert into t values('eric', '01/03/2005 10:25')
insert into t values('bill', '01/03/2005 09:25')
insert into t values('pat', '01/03/2005 06:25')
insert into t values('pat', '01/03/2005 08:25')
insert into t values('eric', '01/03/2005 09:25')
insert into t values('bill', '01/03/2005 09:25')
go
select
colA,
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 6 then
1 end) as [6hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 7 then
1 end) as [7hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 8 then
1 end) as [8hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 9 then
1 end) as [9hr],
count(case when datediff(hour, convert(char(8), colB, 112), colB) = 10 then
1 end) as [10hr]
from
t
group by
colA
order by
colA
drop table t
go
AMB
"TieTo" wrote:
> Hello,
> We someone be so kind to help me out with a (probably simpel) query?
> This is some stripped down sample data to illustrate:
> (two fields, 1 NAME & 1 NAMEDATE)
>
> bill 01/03/2005 06:25
> eric 01/03/2005 07:25
> pat 01/03/2005 07:25
> eric 01/03/2005 09:25
> eric 01/03/2005 10:25
> bill 01/03/2005 09:25
> pat 01/03/2005 06:25
> pat 01/03/2005 08:25
> eric 01/03/2005 09:25
> bill 01/03/2005 09:25
> I am trying to find the count of names per hour period and I am struggling a
> bit. I tried with function 'datepart(hour, NAMEDATE)' but don't get it to
> work.
> The query should in a query result row ...
> NAME 6hr 7hr 8hr 9hr 10hr
> ---
> billl 1 2
> eric 1 2 1
> etc
> So for 'bill' there are 3 records, 1 where hour=06 and 2 where hour=9.
> Eric 4 records, 1 where hour=07; 2 where hour=09 and 1 where hour=10.
> Sorry if my question & layout is a bit blurry ;)
> Rgds,
> T.
>
>|||"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:352EE400-E233-4389-90A6-7A02101A1A91@.microsoft.com...
> Try,
> use northwind
> go
>
<cut>
Hey Alejandro,
Will try your proposed query. Thanks for the reply!!!!
Rgds,
T.

Monday, February 13, 2012

[?] Error accessing from internet

I've installed Reporting Services and customized the authentication ( Forms
Authentication Sample ) with SSL.
Everything works fine in intranet environment.
Now I'm trying to publish this server in internet, but it doesn't work:
when I call the server url I can see the login form, but when I press the
"Login" button nothing happens.
I debugged the application and see the request coming in correctly, the
login credentials are authenticated but the redirect to the
"/Pages/Folder.aspx" is wrong.
It seems like the report manager and the report server can't communicate
each other when accessed from internet.
May the SSL certificate be released on Netbios name but the internet access
is something like www.myserver.com ?
Thanks for responses.
MorenoI had a similar problem. What I did was add a entry into my host file
on the server. Make sure your internal ip for the server matches your
domain name. Hope this helps.
Example:
10.0.0.1 yourssldomain.com
"Moreno" <movendra@.yahoo.com> wrote in message news:<#Q$tpBtWEHA.3800@.TK2MSFTNGP11.phx.gbl>...
> I've installed Reporting Services and customized the authentication ( Forms
> Authentication Sample ) with SSL.
> Everything works fine in intranet environment.
> Now I'm trying to publish this server in internet, but it doesn't work:
> when I call the server url I can see the login form, but when I press the
> "Login" button nothing happens.
> I debugged the application and see the request coming in correctly, the
> login credentials are authenticated but the redirect to the
> "/Pages/Folder.aspx" is wrong.
> It seems like the report manager and the report server can't communicate
> each other when accessed from internet.
> May the SSL certificate be released on Netbios name but the internet access
> is something like www.myserver.com ?
> Thanks for responses.
> Moreno