Viewing 10 posts - 31 through 40 (of 40 total)
Hi,
At the part of eliminate duplicate what if we have a '!' character in string?
So following solution is so simple and suitable for any scenario.
And I use a new way...
May 16, 2010 at 12:11 am
I'd like to group the col0 and get the sum on col2 and use the max date for col3
SELECT col0, SUM(col2) AS sum_col2, MAX(col3) AS max_col3
FROM your_table_name_here
GROUP BY col0
April 28, 2010 at 6:17 am
At last, I got it.
CREATE FUNCTION Cross_tabbing (@product_name VARCHAR(15), @year INT)
RETURNS TABLE AS
RETURN
(SELECT SUM(qty * product_price) AS total
FROM Sales S
WHERE S.product_name = @product_name
...
April 27, 2010 at 12:48 pm
CrazyMan (4/27/2010)
Cool thanks a lot, you made my day 🙂
You are welcome:-)
April 27, 2010 at 9:24 am
INSERT INTO #insert (Txt)
SELECT Txt
FROM #Temp T
CROSS JOIN
(SELECT TOP 100 ROW_NUMBER() OVER(ORDER BY (SELECT 1)) FROM sys.columns)D(n)
WHERE D.n <= T.Cnt
April 27, 2010 at 8:55 am
You are welcome.
Try this also:
SELECT D.Office, ISNULL(D1.d, 0) AS Desktop
,ISNULL(D2.l, 0) AS Laptop
,ISNULL(D3.p, 0) AS Printer
FROM (SELECT DISTINCT Office
FROM table_name) D
OUTER...
April 27, 2010 at 7:25 am
Also
SELECT D.Office,
(SELECT COUNT(*)
FROM table_name
WHERE asset = 'desktop'
AND Office = D.Office) AS 'Desktop'
,(SELECT COUNT(*)
FROM table_name
WHERE asset = 'laptop'
AND Office = D.Office)...
April 27, 2010 at 7:20 am
Also
;WITH Descktop AS
(
SELECT Office, Count(Asset) AS Desktop
FROM stg_AssetSummary
WHERE Asset= 'Desktop'
Group By Office
), Laptop AS
(
SELECT Count(Asset) AS Laptops
FROM stg_AssetSummary
WHERE Asset= 'Laptop'
Group By Office
), Printer AS
(
SELECT Count(Asset) AS Printers
FROM stg_AssetSummary
WHERE Asset= 'Printer'
Group...
April 27, 2010 at 7:15 am
SELECT office,
SUM(CASE WHEN asset = 'desktop' THEN 1 ELSE 0 END) AS [Desktop],
SUM(CASE WHEN asset = 'laptops' THEN 1 ELSE 0 END) AS [Laptops],
SUM(CASE WHEN asset = 'printers' THEN 1...
April 27, 2010 at 7:09 am
April 26, 2010 at 8:29 am
Viewing 10 posts - 31 through 40 (of 40 total)