开发者

Display left value only once

开发者 https://www.devze.com 2023-03-26 08:34 出处:网络
I\'ve got two tables (customer, purchase).I\'ve joined these two tables via the customerid key.This works great.My table looks like:

I've got two tables (customer, purchase). I've joined these two tables via the customerid key. This works great. My table looks like:

Cust_Name | Purchase $
Mike          2.00
Mike          3.00
Mike          4.00
Mike         10.00
Mike         30.00

But what I would like to display is the Cust_name only once (left table) and keep the display of Purchase $开发者_JAVA百科 the same. So it would look like:

Cust_Name | Purchase $
Mike          2.00
              3.00
              4.00
             10.00
             30.00

How do I go about doing this?


I don't believe you can do this easily (I loathe to say at all) with a pure SQL SELECT query. You could run a CURSOR over the table if you create it as a temp table first but but IMO this is a task better suited for your business or presentation layers.


This is not something you should do in a SQL query.

In a relational database, having a dollar amount on the right without a corresponding value on the left to tie it to is essentially meaningless.

Any aesthetic changes like this should be handled in your application or presentation layer, not in the logic of the database.

0

精彩评论

暂无评论...
验证码 换一张
取 消