Showing posts with label appreciate. Show all posts
Showing posts with label appreciate. Show all posts

Monday, March 19, 2012

Need answer to SQL question

I would really appreciate it if someone could give me the answers or direct
me to a place that would have the answers to the following 5 questions.

1. I need an example of SQL select statement. (table tblSource, fields A,B,C
where C<100).. "is this an example that I have in ( )?

2. I need to list 3 table joins or is "inner, outer, left" etc actual table
joins? what are the others for my own knowledge.

3. Can you join a table to itself? (how? Alias.)

4. What is the diff, between distince and distinct row?

5. How would you check a value agains a lookup tableA? (IN) or is "IN" the
answer?

I am very sorry for my stupidy but I am trying to learn and my boss for one
reason or another gave me a ton of questions I cant answer.

Someone please help!"Troy" <corptkm@.yahoo.com> wrote in message news:<ufCXa.3722$Jk5.3134633@.feed2.centurytel.net>...
> I would really appreciate it if someone could give me the answers or direct
> me to a place that would have the answers to the following 5 questions.
> 1. I need an example of SQL select statement. (table tblSource, fields A,B,C
> where C<100).. "is this an example that I have in ( )?

select a,b,c from table where c<100

> 2. I need to list 3 table joins or is "inner, outer, left" etc actual table
> joins? what are the others for my own knowledge.

inner, full outer, left outer, right outer, cross

> 3. Can you join a table to itself? (how? Alias.)

yes. yes.

> 4. What is the diff, between distince and distinct row?

distinct works on a column

> 5. How would you check a value agains a lookup tableA? (IN) or is "IN" the
> answer?

can be - or an inner join. or a left join.

> I am very sorry for my stupidy but I am trying to learn and my boss for one
> reason or another gave me a ton of questions I cant answer.

slap him. or tell him he can live with you rather than paying someone
else a bucket of money to answer his stupid questions...

> Someone please help!

hope we have - expect someone will do it better than me too... :P|||"Troy" <corptkm@.yahoo.com> wrote in message news:<ufCXa.3722$Jk5.3134633@.feed2.centurytel.net>...
> I would really appreciate it if someone could give me the answers or direct
> me to a place that would have the answers to the following 5 questions.
> 1. I need an example of SQL select statement. (table tblSource, fields A,B,C
> where C<100).. "is this an example that I have in ( )?
> 2. I need to list 3 table joins or is "inner, outer, left" etc actual table
> joins? what are the others for my own knowledge.
> 3. Can you join a table to itself? (how? Alias.)
> 4. What is the diff, between distince and distinct row?
> 5. How would you check a value agains a lookup tableA? (IN) or is "IN" the
> answer?
> I am very sorry for my stupidy but I am trying to learn and my boss for one
> reason or another gave me a ton of questions I cant answer.
> Someone please help!

At the risk of appearing cynical, your questions look very like an
academic work assignment, and not much like a series of questions from
your "boss".

I suggest you search Google for "sql tutorial" or something similar,
and you should be able to find some useful discussions of basic SELECT
syntax etc. Or any SQL book will cover the same material. None of your
questions are difficult, so it shouldn't be too much effort to work
them out.

Simon|||Hey, you're not trying to have us do your school homework for you, do you?
Those questions look like a school assignment to me..

;P

Bas

"Troy" <corptkm@.yahoo.com> wrote in message
news:ufCXa.3722$Jk5.3134633@.feed2.centurytel.net.. .
> I would really appreciate it if someone could give me the answers or
direct
> me to a place that would have the answers to the following 5 questions.
> 1. I need an example of SQL select statement. (table tblSource, fields
A,B,C
> where C<100).. "is this an example that I have in ( )?
> 2. I need to list 3 table joins or is "inner, outer, left" etc actual
table
> joins? what are the others for my own knowledge.
> 3. Can you join a table to itself? (how? Alias.)
> 4. What is the diff, between distince and distinct row?
> 5. How would you check a value agains a lookup tableA? (IN) or is "IN" the
> answer?
> I am very sorry for my stupidy but I am trying to learn and my boss for
one
> reason or another gave me a ton of questions I cant answer.
> Someone please help!

Need all Rows:Outer Join + WHERE

Hi, I would appreciate help on the following query I got stuck with;

I've got 2 tables "AccountList" and "PeriodBalance";

I need to return all the accounts form "AccountList" and their balance form "PeriodBalance";

The user will select a period for which the balances should be returned, if there is no balance for the period... 0 should be returned. "PeriodBalance" would not have an entry if there is no balance for the period.

There is only 3 possible periods (1, 2 or 3)

And there is only one balance per period per account;

TABEL 1: AccountList:

AccNo

100

200

300

TABLE 2: PeriodBalance:

AccNo PerID PerBal

100 1 1000

100 2 1750

100 3 1800

300 1 3200

300 3 3500

This is what is what I need returned by the query, assuming we are selecting PerID 2: (WHERE PerID=2)

AccNo PerID PerBal

100 2 1750

200 2 0

300 2 0

I've included ISNULL(PerID,4) = 4 in my WHERE clause...this worked for returning AccNo 200.

My problem is AccNo 300 in not NULL....it has values, just not for the selected PerID...so how do I get AccNo 300 to be included in my Query result?

This is my SQL Query:

SELECT AccountList.AccNo, PeriodBalance.PerID, PeriodBalance.PerBal

FROM AccountList LEFT OUTER JOIN

PeriodBalance ON AccountList.AccNo = PeriodBalance.AccNo

WHERE PeriodBalance.PerID = 2 OR ISNULL(PerID,4) = 4

Thanks in advance;

You should move the filter expression from the "where" clause to the "join".

...

on a.AccNo = p.AccNo and (p.PerID = 2 or p.PerID is null)

AMB

|||

Try this Query

select accountlst.accno,per.perid,per.perbal from
accountlst
left outer join
(select * from PeriodBalance where perid=2) per
on accountlst .accno = per.accno

her u get Perid as null. For this u can replace Per.Perid with the paramter for select perid

declare @.perid int

set @.perid = 2

select accountlst.accno,@.perid,per.perbal from
accountlst
left outer join
(select * from PeriodBalance where perid=@.perid) per
on accountlst .accno = per.accno

|||

Thank you very much Hunchback! That worked just great!

Monday, March 12, 2012

Need advice on hardware for SQL 2005

Hello,
I would appreciate if someone can give some advice on hardware for building
up SQL 2005 cluster. We will have 4 database of 50 GB each. How many
processors, memory,... do I need? My preference is to go for HP servers
Thanks in advanceIt is hard to say, it depends on several factors, specially your budget.
And probably you already know about this, but just in case:
- A 64-bit system is highly recommended.
- The hardware you select must be on the Microsoft Windows Catalog and
Hardware Compatibility List under the cluster category
(http://www.microsoft.com/whdc/hcl/default.mspx)
See Before Installing Failover Clustering on BOL at
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/instsql9/html/a655225d-8c54-4b30-95fd-
31f588167899.htm
Ben Nevarez, MCDBA, OCP
Database Administrator
"Slimo" wrote:

> Hello,
> I would appreciate if someone can give some advice on hardware for buildin
g
> up SQL 2005 cluster. We will have 4 database of 50 GB each. How many
> processors, memory,... do I need? My preference is to go for HP servers
> Thanks in advance
>
>

Need advice on hardware for SQL 2005

Hello,
I would appreciate if someone can give some advice on hardware for building
up SQL 2005 cluster. We will have 4 database of 50 GB each. How many
processors, memory,... do I need? My preference is to go for HP servers
Thanks in advanceIt is hard to say, it depends on several factors, specially your budget.
And probably you already know about this, but just in case:
- A 64-bit system is highly recommended.
- The hardware you select must be on the Microsoft Windows Catalog and
Hardware Compatibility List under the cluster category
(http://www.microsoft.com/whdc/hcl/default.mspx)
See Before Installing Failover Clustering on BOL at
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/instsql9/html/a655225d-8c54-4b30-95fd-31f588167899.htm
Ben Nevarez, MCDBA, OCP
Database Administrator
"Slimo" wrote:
> Hello,
> I would appreciate if someone can give some advice on hardware for building
> up SQL 2005 cluster. We will have 4 database of 50 GB each. How many
> processors, memory,... do I need? My preference is to go for HP servers
> Thanks in advance
>
>