Microsoft
Software
Hardware
Network
Question : SQL sub query help needed
I have this query which works fine:
SELECT tblProject.ID, tblProject.Name, tblProject.PercentComplete
, tblProject.StartDate, tblProject.ScheduledEndDat
e, tblProject.ActualEndDate,
tblCompany.Name AS Company, tblProject_Status.Status
FROM tblProject INNER JOIN
tblCompany ON tblProject.fkCompany = tblCompany.ID INNER JOIN
tblProject_Status ON tblProject.fkStatus = tblProject_Status.ID
ORDER BY tblProject.ID DESC
What I want is to add a column to the results which shows the date of the most recent entry in the tblProject_Blog table so that I can summarize when the last update was made. The sub query should go something like this:
SELECT MAX(DateTime) AS MostRecent
FROM tblProject_Blog
GROUP BY fkProject
Can someone clue me in on how to "connect" these two queries so that the results from the second show up as a column in the results of the first? Thanks!
USE [DGI]
GO
/****** Object: Table [dbo].[tblProject_Blog] Script Date: 07/26/2010 16:34:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tblProject_Blog](
[ID] [int] IDENTITY(1,1) NOT NULL,
[fkProject] [int] NULL,
[fkEmployee] [int] NULL,
[DateTime] [datetime] NULL,
[Text] [varchar](max) NULL,
CONSTRAINT [PK_tblProject_Blog] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[tblProject_Blog] WITH CHECK ADD CONSTRAINT [FK_tblProject_Blog_tblPro
ject] FOREIGN KEY([fkProject])
REFERENCES [dbo].[tblProject] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[tblProject_Blog] CHECK CONSTRAINT [FK_tblProject_Blog_tblPro
ject]
GO
USE [DGI]
GO
/****** Object: Table [dbo].[tblProject] Script Date: 07/26/2010 16:34:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tblProject](
[ID] [int] IDENTITY(1,1) NOT NULL,
[fkCompany] [int] NULL,
[Name] [varchar](128) NULL,
[fkStatus] [int] NULL,
[PercentComplete] [int] NULL,
[StartDate] [date] NULL,
[ScheduledEndDate] [date] NULL,
[ActualEndDate] [date] NULL,
[ProductBuyPrice] [money] NULL,
[ProductSellPrice] [money] NULL,
[ProfessionalServicesBudge
t] [money] NULL,
CONSTRAINT [PK_tblProject] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Answer : SQL sub query help needed
i guess you just need to have nested treemap only.
Also Create an element class with 2 attributes: key and value
something like
TreeMap parentTM = new TreeMap();
TreeMap childTM1 = new TreeMap();
TreeMap childTM2 = new TreeMap();
Element elem1 = new Element(key, value);
...
// Put elements to the map
childTM1.put("1", elem1 );
childTM1.put("2", elem2 );
childTM2.put("1", elem1 );
childTM2.put("2", elem2 );
parentTM.put("1", childTM1 );
parentTM.put("2", childTM2 );
Random Solutions
Time/Date Function Timestamp Incorrect
how to find date when Win7 Home was installed
Anyone knows what this fruit is called in english and if I can buy it in the USA somewhere even online
using setTimeout with window.opener.location.rel
oad();
Validate/Verify US zip codes
DB2 Equivalent of Brackets in Access
Cryptor
Windows 2008 Domain Controller Unavailable (but working)
Converting DNS /DHCP / Print Server using Virtual Machine Manager, Hyper V?
Emc Networker - How can i see full backup size and backup speed?