At 1:54 PM +1000 8/23/07, T&B wrote:
Hi Darren,
It seems to me that you have a flawed design.
Displaying sparse like that should be a function of your application display code, not the database

I had to chuckle that when I asked "How do I use this to do that", your solution was "you shouldn't have that and you should do it with something other than this" ;-) Not really helpful, but good for a chuckle.

Fortunately Simon's replies helped me out.
Hopefully my followup posting gives a better example.

Tom, my answer was quite appropriate, considering your example, and I stand by it.

It is very common that people asking for help are demonstrating that they are heading in a bad direction and want help in dealing with the result of that; I think it is more helpful to assist with the bigger picture than to necessarily support a bad direction.

Or put another way, often when people want to solve problem A, then rather than asking for help in solving problem A, perhaps with some examples of what they tried, they assume that a certain way to go is best, and only ask for help in going that way, that is problem B.

At 1:53 PM +1000 8/23/07, T&B wrote:
But with counts of repetitions, like this:

Day       Room     Subject      Teacher    Period
Monday    A1 1     English   1  Ng     1     1
          A2 2     Maths     1  Peters 2     2
                   Computing 1               3
          H1 1     Sport     1  Kent   1     4
Tuesday   A2 1     Maths     1  Peters 1     1
          A1 3     History   1  Ng     3     2
                   English   1               3
                   History   1               4
Wednesday A2 1     Maths     1  Peters 1     1
          H1 1     Sport     1  Kent   1     2
          S1 2     Science   2  Who    1     3
                                Smith  1     4

The "1" counts could even appear as null/blank, that would be fine.

Now your newer example does demonstrate a more reasonable problem to solve.

By the looks of it you want to display results in a prettier or easier to read grid by having blanks rather than repeated field values; perhaps you are rendering an HTML table, and the numerical count you want is to provide a "rowspan" attribute value. If the DBMS can do this, then your HTML generator would be extremely simple. Or you aren't making HTML, but have similar issues.

That said, if what you want is even possible with SQL, then it would probably be rather verbose SQL, involving multiple joins and group-bys and order-bys etc, and I suspect that your total code size would be smaller if you used appropriate logic in your application to blank the result fields rather than SQL.

So I still recommend you do what you want in your presentation layer rather than in the data layer.

-- Darren Duncan

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to