August 31, 2012 at 3:24 am
Hi,
Select Lnno From Temp_Check
Where det_trantype = 'Opbal'
Group By Lnno
Having Sum(Clbal) <> 0
This query return the output where Sum(Clbal) <> 0,
but In this table ,one more culumn is there trantype .
Now I want same output but except trantype = 'Obal'
That means,even though clbal = 0 for trantype = 'Obal' it should not ignore it.
Please help me !
August 31, 2012 at 3:43 am
You will need to set up some sample data for this, there's a link in my sig to a great article which shows you how it's done.
Without knowing how values of column [trantype] change relative to column [Lnno], it's not possible to give only one query as an answer.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 31, 2012 at 3:43 am
I don't fully understand what you mean, but I think you want something like this, more info would be good (a stab in the dark!)
SELECT Lnno FROM Temp_Check
WHERE det_trantype = 'Opbal'
GROUP BY Lnno
HAVING SUM(Clbal) <> 0
UNION ALL
SELECT Lnno FROM Temp_Check
WHERE det_trantype <> 'Opbal'
GROUP BY Lnno
Andy
==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
August 31, 2012 at 3:53 am
avdhut.k (8/31/2012)
Hi,Select Lnno From Temp_Check
Where det_trantype = 'Opbal'
Group By Lnno
Having Sum(Clbal) <> 0
This query return the output where Sum(Clbal) <> 0,
but In this table ,one more culumn is there trantype .
Now I want same output but except trantype = 'Obal'
That means,even though clbal = 0 for trantype = 'Obal' it should not ignore it.
Please help me !
To help you please help us to get the table DDL and sample data and the required output.
--rhythmk
------------------------------------------------------------------
To post your question use below link
https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
๐
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply