TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shahnid k
NA
61
15.6k
summing and giving where condition for the values less than
Jul 9 2017 5:26 AM
hi
Please help me to resolve the query. i need to get the cells which are having negative figures. Here am selecting the negative figures for the month of january so if i give one more condition for february that "AND (dbo.GLAFS.OPENBAL) + (dbo.GLAFS.NETPERD1) +(dbo.GLAFS.NETPERD1) < 0 " it will delete my first raw of january. That is account id 3506. i have to do this till the month december. How can i do this till december without lossing any rows.
SELECT
ACCTID,FSCSYR,AUDTORG,
SUM
(OPENBAL) +
SUM
(NETPERD1)
as
JAN,
SUM
(OPENBAL) +
SUM
(NETPERD1)+
SUM
(NETPERD2)
as
FEB
FROM
[BIDAT].[dbo].[GLAFS]
where
(
SUBSTRING
(dbo.GLAFS.ACCTID, 1, 4)
BETWEEN
'3251'
AND
'3999'
)
and
FSCSYR= 2016
and
CURNTYPE =
'F'
and
FSCSDSG =
'A'
and
AUDTORG =
'SARRID'
AND
(dbo.GLAFS.OPENBAL) + (dbo.GLAFS.NETPERD1) < 0
group
by
FSCSYR,AUDTORG ,ACCTID
ACCTID
FSCSYR
AUDTORG
JAN
FEB
3506
2016
SARRID
-1800000.000
0.000
3509
2016
SARRID
-3568466.235
-45489664
3510
2016
SARRID
-465846
-784961
3520
2016
SARRID
-545796.265
-5478978.312
Reply
Answers (
1
)
How I create sql database with userName and Password
Get highest 3rd value