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
Datareader object is already open message
PHP/MySQL GROUP BY in query
I want to refresh the desktop in C#, I try to use IActiveDesktop::ApplyChang
es but IActiveDesktop alias is not found as C# underlines it. What should I do?
Server security analysis to determine patch level
Discrete Math, Big O, Little o
10g form won't commit.
I have designed an website in flash as well in html, if the browser dont have flash then i want them to be directed to the html version, or else they need to directed to flash version
Using a hyperlink in a form to open another form with that record's data
Sonicwall E5500 bandwidth/shaping vs Packetlogic PL5600
Windows 2008 R2 x64 Error Id 2092 and Id 4013