‎08-13-2020 11:37 PM
SELECT
ts.Statename,
ts.State,
count(ta.AssetID) AS Total
FROM
tblAssets AS ta
INNER JOIN tblAssetCustom AS tac ON tac.AssetID = ta.AssetID
INNER JOIN tblState AS ts ON ts.State = tac.State
GROUP BY
ts.Statename,
ts.State
ORDER BY ts.Statename
_______________________________
Output:
Statename State Total
Active 1 3994
Harvested 15 2
Inventoried 12 38
Non-active 2 540
Salvaged 10 119
Suspended 14 2
‎08-14-2020 01:14 AM
Select Top 1000000
'http://SERVERNAME:81/Report/report.aspx?det=Web50getdevicebystate&title=All '
+ ts.Statename + ' Assets&@state=' + Convert(NVARCHAR(2),ts.State) As
hyperlink_hyp,
ts.Statename As hyperlink_name_hyp,
Count(ta.AssetID) As Total
From tblAssets As ta
Inner Join tblAssetCustom As tac On tac.AssetID = ta.AssetID
Inner Join tblState As ts On ts.State = tac.State
Group By
'http://SERVERNAME:81/Report/report.aspx?det=Web50getdevicebystate&title=All '
+ ts.Statename + ' Assets&@state=' + Convert(NVARCHAR(2),ts.State),
ts.Statename,
ts.State
Order By hyperlink_name_hyp
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now