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
PHP and concurrent access to files ?
Outlook Contact Consolidation
Windows 2008 server froze. Log files display schannel error.
Send two files in email as attachment in unix shell scripting using ksh
Cisco Rv042 -- how do forwarding rules and firewall access rules work together? And PPTP
make hfsplus partition writable on ubuntu
Help needed to install Team Foundation Server 2010
Error Loading Operating System
Export contact notes from an ACT! 6 database to an Excel or CSV file
C# - Can a partial class override a property's get method?