Groups | Blog | Home
all groups > sql server (alternate) > march 2004 >

sql server (alternate) : UPDATED: Can anyone please help me with this simple sql?



hyper_x_43 NO[at]SPAM yahoo.com
3/27/2004 7:32:48 PM
From: hyper_x_43@yahoo.com (HyperX)
Newsgroups: comp.databases.ms-sqlserver
Subject: Can anyone please help me with this simple sql?
NNTP-Posting-Host: 68.72.235.2
Message-ID: <4de684ec.0403271929.c6ed730@posting.google.com>

Hey guys,

This is a very very simple problem... Can anyone please help me with
this sql?
I'm sure some of you would have come across this problem. I'm hitting
a wall here...

----------------------My select command Begin...--------------
Select User, Item, Price, Qty, (Price * Qty) as Total
From MyTable
----------------------My select command End...--------------


----------------------My result set begin...--------------
user item price qty total
-------------------------------------
Raghu xxx p1 1 t1 <---- t1 = sum for all Raghu items
Raghu yyy p2 2 t1 <---REPETITION - NOT TO BE SHOWN
Raghu zzz p3 2 t1 <---REPETITION - NOT TO BE
SHOWN

Velu yyy p2 2 t2 <---- t2 = sum for all velu items
Velu zzz p3 5 t2 <---REPETITION - NOT TO BE SHOWN

----------------------My result set END...--------------


----------------My Question--------------

What I basically want is to display the item total for Raghu, Velu
etc. only once.

so, my DREAM result set should be

----------------------My DREAM RESULT SET BEGIN...--------------
user item price qty total
-------------------------------------
Raghu xxx p1 1 t1 <---- t1 = sum for all Raghu items
Raghu yyy p2 2 t1
Raghu zzz p3 2 t1
BE SHOWN

Velu yyy p2 2 t2 <---- t2 = sum for all velu items
Velu zzz p3 5 t2
----------------------My DREAM RESULT SET END...--------------


Any help is greatly appreciated.

Thanks in advance.

Simon Hayes
3/28/2004 10:43:45 AM

[quoted text, click to view]

It looks like you've got several responses in another group - please don't
multipost.

Simon

AddThis Social Bookmark Button