Just curious. Can I do this with a view?

Just curious. Can I do this with a view?

Post by JESS » Sun, 16 Feb 2003 00:36:58



Is there anyway I can create dynamically (with a view)a
field, whose value is a string containing the sum of all
of the values displayed up to that time in a certain
field?. I mean:

Field1               Field2
George               George
GeorgeJohn           John
GeorgeJohnPeter      Peter
GeorgeJohnPeterMark  Mark
.....                .......

Field2 is displaying a set of first names. Field1 displays
the sum of all the first names displayed up to that time
in Field2

Is there anyway to do this through a view?.I know this can
be done with a VB recordset or SQL cursor, but I am
wondering if this is possible with a SQL view

Thanks

 
 
 

Just curious. Can I do this with a view?

Post by Joe Celk » Sun, 16 Feb 2003 02:01:54


Quote:>> Field2 is displaying a set of first names. Field1 displays the sum

[SIC] of all the first names displayed up to that time in Field2.  Is
there anyway to do this through a view?.  I know this can be done with a
VB recordset or SQL cursor, but I am wondering if this is possible with
a SQL view  <<

No! Where to begin?? You missed *everything* in your basic relational
database course in school.  

Rows are not records, columns are not fields and tables are not files.
Table have no ordering because they are based on sets.  Columns holds
scalar values (remember 1NF?).  

If you want to do 1950's record-at-a-time file processing, then write a
cursor and lose all the advantages of the relational model for last 30
years.  

--CELKO--
 ===========================
 Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Just curious. Can I do this with a view?

Post by David Brown » Sun, 16 Feb 2003 02:54:06



Quote:> >> Field2 is displaying a set of first names. Field1 displays the sum
> [SIC] of all the first names displayed up to that time in Field2.  Is
> there anyway to do this through a view?.  I know this can be done with a
> VB recordset or SQL cursor, but I am wondering if this is possible with
> a SQL view  <<

> No! Where to begin?? You missed *everything* in your basic relational
> database course in school.

> Rows are not records, columns are not fields and tables are not files.
> Table have no ordering because they are based on sets.  Columns holds
> scalar values (remember 1NF?).

> If you want to do 1950's record-at-a-time file processing, then write a
> cursor and lose all the advantages of the relational model for last 30
> years.

A little rough, don't you think Joe.

Oracle can do this in a view quite easilly,
just happens that SQLServer cannot.

And Joe, a Set is ordered just as soon as you impose
an ordering on it.  A relation is a subset of the cross
product of some sets (called domains).  A domain may
have an ordering, and any ordering on a domain is extendable
to an ordering on the any relation involving that domain.

Moreover when we store data in relational databases we
expect to be able to answer questions about that data.

For instance it's quite easilly generate a year-to-date total
in SQL, it's just hard to put the year-to-date column on a
result grouped by month.  This really just a shortcoming
of ANSI SQL, and doesn't have any bearing on relational theory.

David

 
 
 

Just curious. Can I do this with a view?

Post by JESS » Sun, 16 Feb 2003 02:55:06


I just posted a question. I did not ask for you personal
opinion, Mr Expert. No was enough as an answer. What about
you?. Do you know everything about everything?. I do not
think so.

No thanks this time, Mr Expert

Quote:>-----Original Message-----
>>> Field2 is displaying a set of first names. Field1
displays the sum
>[SIC] of all the first names displayed up to that time in
Field2.  Is
>there anyway to do this through a view?.  I know this can
be done with a
>VB recordset or SQL cursor, but I am wondering if this is
possible with
>a SQL view  <<

>No! Where to begin?? You missed *everything* in your
basic relational
>database course in school.  

>Rows are not records, columns are not fields and tables
are not files.
>Table have no ordering because they are based on sets.  
Columns holds
>scalar values (remember 1NF?).  

>If you want to do 1950's record-at-a-time file

processing, then write a
Quote:>cursor and lose all the advantages of the relational
model for last 30
>years.  

>--CELKO--
> ===========================
> Please post DDL, so that people do not have to guess
what the keys,
>constraints, Declarative Referential Integrity,

datatypes, etc. in your

- Show quoted text -

Quote:>schema are.

>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.

 
 
 

Just curious. Can I do this with a view?

Post by JI » Sun, 16 Feb 2003 03:26:18


Not sure about a view but here is some sql that will do
what you are asking




  from Table

At least this eliminates a cursor.

Quote:>-----Original Message-----
>Is there anyway I can create dynamically (with a view)a
>field, whose value is a string containing the sum of all
>of the values displayed up to that time in a certain
>field?. I mean:

>Field1               Field2
>George               George
>GeorgeJohn           John
>GeorgeJohnPeter      Peter
>GeorgeJohnPeterMark  Mark
>......                .......

>Field2 is displaying a set of first names. Field1
displays
>the sum of all the first names displayed up to that time
>in Field2

>Is there anyway to do this through a view?.I know this
can
>be done with a VB recordset or SQL cursor, but I am
>wondering if this is possible with a SQL view

>Thanks

>.

 
 
 

Just curious. Can I do this with a view?

Post by Michael MacGrego » Sun, 16 Feb 2003 03:32:03


If you'd've spent sometime around here, you'd know that Joe is just like
that. Don't take it personally. He is an extremely knowledgable DBA, though
not necessarily specifically with regard to MS SQL, he has written a couple
of books, again not specific to MS SQL. Though like many people around here,
he is very passionate about SQL and holds some very strong opinions, nothing
wrong with that, so just take a deep breath and relax. His style may be a
bit abrasive at first but after a bit, you come to know him and love him,
well love maybe too strong a word, maybe like, er, well, that's probably too
strong a word too, let's just leave it at know him. :-)

Michael MacGregor
Database Architect
SalesDriver

 
 
 

Just curious. Can I do this with a view?

Post by Michael MacGrego » Sun, 16 Feb 2003 03:33:37


I think though the first thing I'd ask is why? What on earth is JESS trying
to accomplish with this?

Michael MacGregor
Database Architect
SalesDriver

 
 
 

Just curious. Can I do this with a view?

Post by JI » Sun, 16 Feb 2003 03:48:29


Don't know don't care. While I do advocate good design and
don't like this particular design...he asked a question
and I replied. This is not the forum for us to get on soap
boxes.
Quote:>-----Original Message-----
>I think though the first thing I'd ask is why? What on

earth is JESS trying
Quote:>to accomplish with this?

>Michael MacGregor
>Database Architect
>SalesDriver

>.

 
 
 

Just curious. Can I do this with a view?

Post by Jacco Schalkwij » Sun, 16 Feb 2003 03:56:28


Joe,

A while ago I read "Database design for mere mortals" by Micheal J.
Hernandez, which I think is as good an introduction to relational database
ideas as you can get before going on to learn all the formal theory, and he
uses the records and fields terminology as well. Just because someone says
"records" and "fields" instead of "rows" and "columns" doesn't mean that
s/hemissed all the concepts.

Jacco


Quote:> >> Field2 is displaying a set of first names. Field1 displays the sum
> [SIC] of all the first names displayed up to that time in Field2.  Is
> there anyway to do this through a view?.  I know this can be done with a
> VB recordset or SQL cursor, but I am wondering if this is possible with
> a SQL view  <<

> No! Where to begin?? You missed *everything* in your basic relational
> database course in school.

> Rows are not records, columns are not fields and tables are not files.
> Table have no ordering because they are based on sets.  Columns holds
> scalar values (remember 1NF?).

> If you want to do 1950's record-at-a-time file processing, then write a
> cursor and lose all the advantages of the relational model for last 30
> years.

> --CELKO--
>  ===========================
>  Please post DDL, so that people do not have to guess what the keys,
> constraints, Declarative Referential Integrity, datatypes, etc. in your
> schema are.

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

 
 
 

Just curious. Can I do this with a view?

Post by Michael MacGrego » Sun, 16 Feb 2003 03:58:33


Quote:> Don't know don't care. While I do advocate good design and
> don't like this particular design...he asked a question
> and I replied. This is not the forum for us to get on soap
> boxes.

You might not, others don't necessarily agree with you. And this is not
about getting on a soap box. When trying to help newbies and those less
experienced, it's often better to figure out what they are trying to do
rather than simply giving a pat answer to their question. Do you advocate
the use of cursors where a set oriented solution would be better but you
provide the cursor solution simply because that is what they asked for? Bit
blinkered isn't it?

Michael MacGregor
Database Architect
SalesDriver

 
 
 

Just curious. Can I do this with a view?

Post by JI » Sun, 16 Feb 2003 04:28:33


First, did i supply a cursor oriented answer? While it is
one that Anith finds unreliable and on the surface I would
think adding system functions and distinct within the
solution would cause the engine to get confused.

I completely agree with you on the context of finding out
as much details as they are willing to give you. The
assistance found here is great but the context of Joe's
message was a bit harsh, regardless of his tenure. I, too,
am an experienced DBA and while I don't think I have all
of the right answers I don't treat people as if they are
doing stupid things. We all have gone through the bad
design periods and have our own growing pains to talk
about and neither of us would have appreciated ridicule at
that time.

Quote:>-----Original Message-----
>> Don't know don't care. While I do advocate good design
and
>> don't like this particular design...he asked a question
>> and I replied. This is not the forum for us to get on
soap
>> boxes.
>You might not, others don't necessarily agree with you.
And this is not
>about getting on a soap box. When trying to help newbies
and those less
>experienced, it's often better to figure out what they
are trying to do
>rather than simply giving a pat answer to their question.
Do you advocate
>the use of cursors where a set oriented solution would be
better but you
>provide the cursor solution simply because that is what
they asked for? Bit
>blinkered isn't it?

>Michael MacGregor
>Database Architect
>SalesDriver

>.

 
 
 

Just curious. Can I do this with a view?

Post by Michael MacGrego » Sun, 16 Feb 2003 04:37:21


Quote:> First, did i supply a cursor oriented answer?

Did I say that you did? It's called a hypothetical question.

Quote:> I completely agree with you on the context of finding out
> as much details as they are willing to give you. The
> assistance found here is great but the context of Joe's
> message was a bit harsh, regardless of his tenure. I, too,
> am an experienced DBA and while I don't think I have all
> of the right answers I don't treat people as if they are
> doing stupid things. We all have gone through the bad
> design periods and have our own growing pains to talk
> about and neither of us would have appreciated ridicule at
> that time.

We all have our idiosyncracies and peculiar characteristics. Anybody who
knows Joe knows that is how he is, bit tough on the guys who don't know that
but really this is a free service and they shouldn't get upset by the
responses they receive. Joe isn't out to ridicule anyone and if you have any
experience of his responses you'd know that.

MTM

 
 
 

1. MDX : Canned Report or OLAP

Here is the requirement spec for a report about various
values(items below) for different projects.

item#1 item#2 item#5For2001 item#5For2002 item#6For2001 ...

Here item#1 and 2 are measured in general for the entire
lifecyle of the project, item#5 & item6 is being reported
yearwise. Can this kinda of data be stored in a single
cube? If Yes then what will be the MDX query to fetch the
data in above format.

Thanks,

Ashu

2. SQL JOB - Performing Completion Action

3. Anyone know of some canned (cheap or free) DB performance testing software

4. database to connect to for stock data

5. canned code to get db on web quickly via perl or

6. Case sensitivity

7. Cans access2.0 engine access btrieve files?

8. Delete a DTS Metadata

9. bcp canned app

10. if you will promise Allahdad's swamp against cans, it will angrily depart the unit

11. Switching from inhouse to canned package.

12. Canned PARADOX scripts?