Posted by selectall on August 9, 2009
select stud_id , group_concat(paper_id) as i from tb
group by id
Original Table:
stud_id paper_id
1 1
1 2
1 3
1 4
2 2
2 3
3 1
4 2
Output:
stud_id paper_id
1 1,2,3,4
2 2,3
3 1
4 2
Posted in MS SQL 2005, Mysql Stuff | Tagged: concat multiple values of single column, concat values of single column in sql, creating a single field from multiple row results | Leave a Comment »
Posted by selectall on July 8, 2009
SELECT id as student_id,
student_code,
‘Present’ AS attendance_legend_name,
first_name
FROM dbo.ad_student_m
Posted in MS SQL 2005 | Tagged: add column, add column in query, add column in query with default value, add column using query, add dummy column in query, column in query with default value, temparary column in query | Leave a Comment »
Posted by selectall on July 4, 2009
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
CREATE FUNCTION [GetAmount]
(
@Amount decimal,
@Interest decimal,
@Tax decimal
)
RETURNS Decimal(10,2)
AS
BEGIN
DECLARE @TAmount decimal(10,2);
set @TAmount = @Amount + @Interest + @ServiceTax
RETURN @TAmount;
END
Posted in MS SQL 2005 | Tagged: Scalar-valued Functions, Scalar-valued Functions by example, Scalar-valued Functions in sql server | Leave a Comment »
Posted by selectall on July 1, 2009
SELECT DATEDIFF(day, DATE_MODIFIED, GETDATE()) AS no_of_days FROM EDITVIEWS_FIELDS
Posted in MS SQL 2005 | Tagged: Date Difference, Date Difference in sql2005, difference between twod dates, difference between twod days | Leave a Comment »
Posted by selectall on July 1, 2009
CONVERT(nvarchar(8), dbo.fs_deposit_m.date_of_deposition, 112) BETWEEN 20090201 AND 20090302
Posted in MS SQL 2005 | Tagged: Date between tow dates, Date between tow dates in sql, Date between tow dates in sql 2005, find date | Leave a Comment »