Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem grouping columns on Date

Status
Not open for further replies.

rpk2006

Technical User
Apr 24, 2002
225
IN
I have a Table in SQL Server which contains following fields:

Date, Amount, Particulars

I want to save the results in a new table like this:

DATE PARTICULARS AMOUNT
------- ------------------ -----------
20/10/04 abc 38383
DEF 958
ghi 18393
21/10/04 Xyz 78338
hsius 838
22/10/04 jhdljkhj 873883
kljkdfljk 73733
jhjhfjjh 838738

Above you can see how the "Particulars" and "Amount" are grouped on "Date".

I used the following query:

"Select Distinct Date,Particulars,Amount
From Transac
Where Custid = 95
Order By Date"

However the above query does not fetch the result as I needed. It does not group like what I have shown above.

How to write the query?
 
Is the time also contrained within your date field?

When you write this query the date will appear on each row. You'll have to remove it on the front end if you want it removed.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
This is a report (presentation layer) issue, not a SQL one.
 
As was said, this is a presentation issue. If you want what you are seeing, you'll need to run it through an application program to remove all the dates after the first one.

Now if you're not getting the rows back as you would want (with all DATE showing), then write back.
 
Post in the SQL Server forum if you don't know how to write a cursory stored procedure to achieve that you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top