dbTalk Databases Forums  

Concat instead of SUM when grouping results

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Concat instead of SUM when grouping results in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Greg D. Moore \(Strider\)
 
Posts: n/a

Default Re: Concat instead of SUM when grouping results - 11-26-2007 , 07:09 AM






"Bart op de grote markt" <warnezb (AT) googlemail (DOT) com> wrote

Quote:
On 25 nov, 19:59, --CELKO-- <jcelko... (AT) earthlink (DOT) net> wrote:
I guess there is no function to do this... What is the simplest
solution?

Do it in the front end instead violating 1NF in the Database side.

Hi,

I'm not an expert in that area, but I thought NF had to do with
database design and not with querying a database? Correct me if I'm
wrong.
You're "wrong".

You can't really separate the two. That's like saying that wheels on a car
have to do with the design, not with the actual driving.

If you design your database properly, your queries follow from that.


Quote:
I would like most of the logic on server side, (the report result is
retrieved by an excel report that mainly adds lay-out and adds the
possibility to further process the results) because when an update of
the report is needed, I only need to change the stored procedure and
not the 'front-end' excel reports with everybody that uses it.

Then do it in a middle layer. What happens when your DB changes for other
reasons but your reports aren't supposed to?


Quote:
Kind regards,

Bart


--
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html




Reply With Quote
  #12  
Old   
jhofmeyr@googlemail.com
 
Posts: n/a

Default Re: Concat instead of SUM when grouping results - 11-26-2007 , 07:56 AM






Quote:
If you design your database properly, your queries follow from that.
This is nice in theory, but in practice I have seen many occasions
where reporting requirements simply don't align with the database
(which you often have no control over and may have been designed for
an input system for example). Short of designing a new database and
ETL'ing your data across (which there certainly is a market for but in
a lot of cases would be overkill to meet a single requirement),
sometimes you have to write "non-standard" queries.

Quote:
Then do it in a middle layer. What happens when your DB changes for other
reasons but your reports aren't supposed to?
Why would a stored procedure not qualify as a middle layer? It
provides a convenient interface between the front-end and the database
and still allows the use of this type of query which, in my opinion,
is neat and easy to implement in SQL. Does it matter if your entire
data structure underneath the stored proc changes as long as the proc
continues to serve up the same results?

J


Reply With Quote
  #13  
Old   
Bart op de grote markt
 
Posts: n/a

Default Re: Concat instead of SUM when grouping results - 11-26-2007 , 09:52 AM



On 26 nov, 14:09, "Greg D. Moore \(Strider\)"
<mooregr_deletet... (AT) greenms (DOT) com> wrote:
Quote:
"Bart op de grote markt" <warn... (AT) googlemail (DOT) com> wrote in messagenews:3e7b897e-7ff7-436f-9291-adc2ab732c32 (AT) s36g2000prg (DOT) googlegroups.com...

On 25 nov, 19:59, --CELKO-- <jcelko... (AT) earthlink (DOT) net> wrote:
I guess there is no function to do this... What is the simplest
solution?

Do it in the front end instead violating 1NF in the Database side.

Hi,

I'm not an expert in that area, but I thought NF had to do with
database design and not with querying a database? Correct me if I'm
wrong.

You're "wrong".

You can't really separate the two. That's like saying that wheels on a car
have to do with the design, not with the actual driving.

If you design your database properly, your queries follow from that.
I have not said that database design has nothing to do with querying a
database... But a query of a database is combining the available data
to hava a certain result. Putting the normal forms into your database
is a way to avoid data loss in your database when you update or delete
your data. If I query a database for a report, then the result won't
interfere with the database itself, it just gives a view on your data.
I don't want to be offensive or so, but I'm not convinced yet.

And ok, I did not design the database... it is a database from a new
application my company bought. (In fact it's about two databases from
two different applications that have to be linked in a report, but I
won't go too far to explain that :-) )

Quote:
I would like most of the logic on server side, (the report result is
retrieved by an excel report that mainly adds lay-out and adds the
possibility to further process the results) because when an update of
the report is needed, I only need to change the stored procedure and
not the 'front-end' excel reports with everybody that uses it.

Then do it in a middle layer. What happens when your DB changes for other
reasons but your reports aren't supposed to?

As has been said by J above, the Stored Procedure acts as middle layer
between the database and the reports. If there is an update of the
database (e.g. new product version), I will adapt the stored
procedure, so that the user doesn't even notice that anything has
changed.


Kind regards and thx for all your comments

Bart


Reply With Quote
  #14  
Old   
Tony Rogerson
 
Posts: n/a

Default Re: Concat instead of SUM when grouping results - 11-26-2007 , 03:16 PM



Quote:
You're "wrong".
Actually Greg - You're "wrong".

SQL Server is a data engine and not just a relational data storage method.

There are lots and lots of extensions and features in SQL Server to help us
gain more performance, more simplicity instead of having to code stuff in
the middle tier all the time.

For instance, if I was writing a data export why on earth would I want to
use a second programming langauge that adds complexity when I can easily use
the functions and features in T-SQL.

There is a move more to putting business logic in the data engine rather
than just using the data engine as a put and get object - see research by
Jim Gray.

Quote:
Then do it in a middle layer. What happens when your DB changes for other
reasons but your reports aren't supposed to?
It would be a bigger change if you had done it in the middle tier - both the
data access queries would change AND the middle tier source code. That's a
lot more testing, development - it's higher risk, more complicated etc...

--
Tony Rogerson, SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson
[Ramblings from the field from a SQL consultant]
http://sqlserverfaq.com
[UK SQL User Community]



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.