Viewing 15 posts - 616 through 630 (of 3,543 total)
Yes you are correct
the line 'ORDER BY CASE WHEN COMPANY_ROLE_CD = 'BK' THEN 1 ELSE 2 END ASC) AS [ROWID]'
puts the most desirable name at row 1 ie BK first
You...
November 17, 2014 at 10:47 am
LEFT JOIN (
SELECT BOOKING_ID,
CASE WHEN COMPANY_ROLE_CD = 'BK' OR BOOKED_BY_FLG = 'Y'
THEN PARTY_NAME
ELSE NULL
END AS [BOOKING PARTY],
ROW_NUMBER() OVER (
PARTITION BY BOOKING_ID
ORDER BY CASE WHEN COMPANY_ROLE_CD = 'BK' THEN...
November 14, 2014 at 9:21 am
Can there be more than one row in MiniGapp..MG_BOOKING_PARTY table for a BOOKING_ID?
If so how do you determine which one?
If not then you do not need a sub query.
November 14, 2014 at 6:55 am
However max(rate) over( partition by product) will not work if the rate varies +/- and the latest value by date is needed
November 12, 2014 at 6:21 am
serg-52 (11/12/2014)
max(rate) over( partition by product)
Nice 🙂
I did not think of that :blush:
November 12, 2014 at 6:19 am
Use case to pivot the data, ie
WITH cte (ACCOUNT,CODE,ColNo) AS (
SELECT ACCOUNT,CODE,
ROW_NUMBER() OVER (PARTITION BY ACCOUNT ORDER BY CODE)
FROM )
SELECT ACCOUNT,
MAX(CASE WHEN ColNo=1 THEN CODE END) AS [CODE1],
MAX(CASE WHEN ColNo=2...
November 12, 2014 at 6:16 am
SELECTDATENAME(month,DATEADD(month,MONTH(t.Bill_date),0)) AS [Month],
t.product,
SUM(t.QTY) AS [QTY],
r.rate,
SUM(t.total_val) AS [T_val]
FROMtest t
CROSS APPLY (SELECT TOP 1 rate from test ORDER BY Bill_date DESC,rate DESC) r
GROUPBY MONTH(t.Bill_date),t.product,r.rate
ORDERBY MONTH(t.Bill_date)
November 12, 2014 at 6:03 am
Just a guess, try using a LEFT JOIN?
SELECT table1.column1, table2.column1 as SomeRandomColumnName, CAST(CASE WHEN table2.column1 IS NULL THEN 1 ELSE 0 END AS bit)
AS BitValueColumnName
FROM table2 LEFT JOIN
...
November 4, 2014 at 6:39 am
If the parameters are integers
DECLARE @Month int = 2
DECLARE @Year int = 2014
SELECT
DATEADD(month,(@Year*12-22800)+(@Month-1),0) AS [SatrtDate],
DATEADD(daY,-1,DATEADD(month,(@Year*12-22800)+@Month,0)) AS [EndDate]
October 16, 2014 at 8:36 am
Previous replies notwithstanding
STUFF(CONVERT(varchar(12),DATEADD(month,2,dd.date),107),1,3,DATENAME(MM,DATEADD(month,2,dd.date)))
October 16, 2014 at 7:44 am
SELECTj.name AS JobName
, c.name
, c.path
, c.description
, rs.SubscriptionID
, laststatus
, eventtype
, LastRunTime
, date_created
, date_modified
FROMReportServer.dbo.[Catalog] c
JOIN ReportServer.dbo.Subscriptions s
ON s.report_oid = c.itemid
JOIN ReportServer.dbo.ReportSchedule rs
ON rs.SubscriptionID...
September 11, 2014 at 7:08 am
Stefan Krzywicki (9/10/2014)
Date columns as a varchar(7). What are you even putting in there? Still better than the date columns as Timestamp I guess.
Ordinal Date? 😀
September 10, 2014 at 9:41 am
My answer, FWIW, would be to remove the year filter from the dataset and add it to the column expression instead.
e.g.
Sum(IIf(Year = Year(Now)-1,Fields!SentLeads.Value),0) for last year
Sum(IIf(Year = Year(Now),Fields!SentLeads.Value),0) for this...
September 10, 2014 at 3:07 am
jcrawf02 (9/3/2014)
My wife keeps telling me I need to stop swearing around the two year old. I'm going to replace swearing with database jargon randomness now...
Flaming Firehose Cursors!
Backwards Compatibility!
Great Moden's...
September 3, 2014 at 6:45 am
Viewing 15 posts - 616 through 630 (of 3,543 total)