Viewing 15 posts - 271 through 285 (of 898 total)
One way to do this
DECLARE@person TABLE
(
person_name VARCHAR(50),
date_of_birth CHAR(8)
)
DECLARE@start_date CHAR(4)
DECLARE @end_date CHAR(4)
INSERT@person
SELECT 'A', '19800101' UNION ALL
SELECT 'B', '19700605' UNION ALL
SELECT 'C', '19650525' UNION ALL
SELECT 'D', '19901020'
SET@start_date = RIGHT(CONVERT(CHAR(8),CURRENT_TIMESTAMP,112),4)
SET@end_date = RIGHT(CONVERT(CHAR(8),DATEADD(DAY,29,CURRENT_TIMESTAMP),112),4)
SELECT*
FROM@person
WHERERIGHT(date_of_birth,4) BETWEEN...
May 21, 2013 at 1:28 am
eklavu (5/21/2013)
DECLARE @TABLE_NAME TABLE(
NAME VARCHAR(30),
BDAY CHAR(8))
INSERT INTO @TABLE_NAME(NAME,BDAY)
VALUES('A','20130522')
INSERT INTO @TABLE_NAME(NAME,BDAY)
VALUES('B','20130523')
INSERT INTO @TABLE_NAME(NAME,BDAY)
VALUES('C','20130524')
INSERT INTO @TABLE_NAME(NAME,BDAY)
VALUES('D','20130525')
INSERT INTO @TABLE_NAME(NAME,BDAY)
VALUES('E','20130521')
INSERT INTO @TABLE_NAME(NAME,BDAY)
VALUES('F','20130620')
SELECTNAME,
DATEDIFF(DAY,GETDATE(), CAST(BDAY AS DATETIME)) [BDAY WITHIN 30 DAYS]
FROM@TABLE_NAME
WHEREDATEDIFF(DAY,GETDATE(), CAST(BDAY AS...
May 21, 2013 at 1:15 am
In that case you can use ROW_NUMBER() to get the desired result
With MyCTE (clientName,col2,col3,col4)
AS
(
SELECT 'A123','val1','val2','val3' UNION ALL
SELECT 'A123','val4','val5','val6' UNION ALL
SELECT 'B234','val7','val8','val9' UNION ALL
SELECT 'C789','val1','val5','val6' UNION ALL
...
May 21, 2013 at 1:02 am
You will need CASE statement and some hard-coding to achieve this result
SELECTCASE WHEN SUM(trans_amt) BETWEEN -0.99 AND 0 THEN '-0.00' ELSE CAST( SUM(trans_amt) AS VARCHAR(30)) END
FROMacc_bal_may
May 20, 2013 at 4:22 am
Getting -0 as result after performing some numeric operation is not possible
We will have to do some string concatenation to achieve this result
Can you give a bit more details as...
May 20, 2013 at 2:44 am
kunal.desai 7690 (5/19/2013)
Hey,Many many thanks,
This worked like a gem. I met my objective with this solution.
Regards,
K
Glad I could help you out 🙂
May 20, 2013 at 1:32 am
I don't think you require a CURSOR to do this kind of stuff
Please go through the article in my signature and give us the DDL of the tables involved, some...
May 18, 2013 at 4:38 am
We may need non set-based methods to achieve the result you need
I have a set-based solution which gives you different results in terms of numbers, but the objective is the...
May 18, 2013 at 4:30 am
adonetok (5/16/2013)
Now, I...
May 16, 2013 at 8:22 am
adonetok (5/16/2013)
I do not think that without loop can do it.
Can someone...
May 16, 2013 at 8:10 am
Your requirements are not very clear
Can you provide the DDL of the tables involved, data and the expected results in a ready to use format
Please check the link in my...
May 16, 2013 at 7:47 am
Please post the exact error message that you are getting.
April 29, 2013 at 9:09 am
One way of doing this..
SELECTa.name, b.[DATE], b.[ORDER]
FROMdbo.Table_A a
LEFT OUTER JOIN(
SELECTROW_NUMBER() OVER( PARTITION BY b.ID ORDER BY b.[DATE] DESC ) AS RN, *
FROMdbo.Table_B AS b
) AS b ON a.id = b.ID...
April 29, 2013 at 9:00 am
One more way to do this..
SELECT*
FROMmain AS m
WHERE NOT EXISTS( SELECT * FROM doc AS d WHERE m.fileno = d.fileno AND d.code = 'I' )
We can't say that one method...
April 29, 2013 at 8:51 am
kgeeel240 (4/29/2013)
Thank you it worked!!!!:w00t:
Glad it helped:-)
April 29, 2013 at 7:55 am
Viewing 15 posts - 271 through 285 (of 898 total)