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
Gridview Update not saving. Fields stay in edit mode.
use wireshark to capture whats happening during the logon process
SBS 2008: reverting from smart host/pop3 connector to exchange hosted email (DNS)?
How to read the data from MQRFH2 messages using MQ connector stage
Split word document and save based on tags
Need SBS 2008 R2 Premium Media
Win 2003 Server desktop icons do not appear after login
How do create a Windows batch script to start a service and set to automatic
My Computer/ Explorer Not responding Windows XP
Internet Explorer blocking javascript