on 07-20-2010 4:54 AM
Hi All,
I have a working query that returns all AR Invoices posted Yesterday excluding weekends.
There are however no drill down yellow arrows in the result for DocNum. Is there a way I can restructure my query so the drill own arrows appear?
declare @dt_today datetime,
@dt_yesterday datetime
select @dt_today = DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)
select @dt_yesterday = case DATEPART(DW,@dt_today)
when 2 then DATEADD(dd, -3, @dt_today)
when 1 then DATEADD(dd, -2, @dt_today)
else DATEADD(dd, -1, @dt_today) end
SELECT T0.[DocNum] As 'Invoice number', T0.[DocDate] As 'Posting Date',
T0.[DocTotal] As 'Invoice Total', T0.[GrosProfit] As 'Gross Profit',
((T0.[GrosProfit] / (T0.[DocTotal] - T0.[GrosProfit]))*100) As 'Profit %',
T1.[CardCode], T1.[CardName], T0.[NumAtCard] As 'Customer PO#', T2.[GroupName],
T1.[Phone1], T1.[CntctPrsn]
FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCRG
T2 ON T1.GroupCode = T2.GroupCode WHERE T0.[DocDate] = @dt_yesterday
Hi John,
You could add the T0.[DocEntry] column to your query so that you get a drill down link. If you use AS in the query add FOR BROWSE at the end of the SQL query, however if you want to use just DocEntry without AS there is no need to add the FOR BROWSE.
declare @dt_today datetime,
@dt_yesterday datetime
select @dt_today = DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)
select @dt_yesterday = case DATEPART(DW,@dt_today)
when 2 then DATEADD(dd, -3, @dt_today)
when 1 then DATEADD(dd, -2, @dt_today)
else DATEADD(dd, -1, @dt_today) end
SELECT T0.[DocEntry] AS 'Invoice JE', T0.[DocNum] As 'Invoice number', T0.[DocDate] As 'Posting Date',
T0.[DocTotal] As 'Invoice Total', T0.[GrosProfit] As 'Gross Profit',
((T0.[GrosProfit] / (T0.[DocTotal] - T0.[GrosProfit]))*100) As 'Profit %',
T1.[CardCode], T1.[CardName], T0.[NumAtCard] As 'Customer PO#', T2.[GroupName],
T1.[Phone1], T1.[CntctPrsn]
FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCRG
T2 ON T1.GroupCode = T2.GroupCode WHERE T0.[DocDate] = @dt_yesterday
FOR BROWSE
Best,
Paul.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Zal,
I hope you don't leave the forum. I (along with others I assume) need all the help I can get
Gordon's select statement was more elegant than my original query attempt but your solution worked absolutely perfectly and offered a great heads up for my future attempts. Thanks again.
Best,
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks to you both.
The For Browse solution works with the original query. This being said, Gordon's solution is a much more elegant select statement.
Many thanks to you both.
Regards,
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this way:
SELECT T0.DocNum As 'Invoice number', T0.DocDate As 'Posting Date',
T0.DocTotal As 'Invoice Total', T0.GrosProfit As 'Gross Profit',
((T0.GrosProfit / (T0.DocTotal - T0.GrosProfit))*100) As 'Profit %',
T1.CardCode, T1.CardName, T0.NumAtCard As 'Customer PO#', T2.GroupName,
T1.Phone1, T1.CntctPrsn
FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCRG
T2 ON T1.GroupCode = T2.GroupCode
WHERE DATEDIFF(DD, T0.DocDate, GetDate()) = 1 OR (DATEDIFF(DD, T0.DocDate, GetDate()) = 3 AND DATEPART(dw,GetDate()) in (1,2))
If still no arrow, add For Browse.
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello John -
I did not test your SQL but one thing I always do is put a FOR BROWSE at the end of each SQL that I write. In many instances, that will get those orange arrows back! Sometimes you cannot use the FOR BROWSE, due to sums and all, but that is a good final step to take each time you write SQL...
Hope that helps,
Zal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.