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
Word 2003 - working with tables, rows, and cells
A Perl Script to get windows server information
Do WPF and MVP go together?
Windows batch file to trigger e-mail notification.
How deploy a website shortcut to 200 users desktop
What is the best Server Antivirus going right now? What are you guys using?
Can't print to Dymo Labelwriter 400 turbo after adding labelwriter 450 turbo drivers on windows 2003 terminal server
Having a problem seeing USB devices after installing libusb - NO KEYBOARD OR MOUSE !!
error while installing Exchang 2010
In .NET, how can I add to a variable value to a query result using LINQ to SQL?