| Author |
Topic  |
|
|
bkbinani
Starting Member
India
15 Posts |
Posted - 09/28/2012 : 00:24:08
|
I wish to pick up only Distinct uPartyID from a Trn File with a date range. I must consider Those UpartyId whose at least any balance b4 startind date or any Transaction within date range.
I had tried with following codes but it does not show Distinct uPartyID instead same uPartyID comes twise or more.
Plz Help.
My Tables: DAT_TRN (Trns Table ) MST_LED (Master Table)
My Codes:
quote: ** -- Target to Picup unique uPartyID declare @nTotQty numeric(10), @yesno Bit set @nTotQty = 0 SET @yesno = 0
Select uPartyId,cLedName, @nTotQty as nTotQty, @yesno as yesno from DAT_trn Join mst_led on uledCode = uPartyID where dTrnDate between ?m.pdFrom and ?m.pdUpto UNION Select uPartyID,cLedName, Sum(nQnty) as nTotQty ,@yesno as yesno from dat_trn Join mst_led on uledCode = uPartyID where dTrnDate < ?m.pdFrom group by uPartyId, cLedName, cMkt_Type, cSymbol, dExpiry, nStrike Order by cLedName
|
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 09/28/2012 : 10:22:01
|
whats are column in your table? show some sample data and give expected output
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
bkbinani
Starting Member
India
15 Posts |
Posted - 09/29/2012 : 01:03:16
|
quote: Originally posted by visakh16
whats are column in your table? show some sample data and give expected output
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
Thanx for reply sir. My hats-off 2 u for being a MVP.
dbo.DAT_TRN Fields: cMkt_type c(5), dtrnDate datetime,UpartyID UID, cSymbol c(15), dExpiry datetime, nQnty number(10) , cTags c(5), nStrike Number(14,4)
dbo.MST_LED Fields: uLedCode UID, cLedName C(45), iAutoid (i) (** Here UledCode is PK)
hope this help. Please sir.
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 10/01/2012 : 11:09:39
|
hmm..is this sql server? whats c(5) etc? I dont think this is t-sql
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|
|
|