Click here to Skip to main content
16,005,178 members
Home / Discussions / Database
   

Database

 
AnswerRe: displaying a data in textbox Pin
Colin Angus Mackay15-Jul-07 23:28
Colin Angus Mackay15-Jul-07 23:28 
GeneralRe: displaying a data in textbox Pin
Rharzkie15-Jul-07 23:59
Rharzkie15-Jul-07 23:59 
GeneralRe: displaying a data in textbox Pin
Colin Angus Mackay16-Jul-07 0:53
Colin Angus Mackay16-Jul-07 0:53 
QuestionDate format in cell Pin
Sam Heller15-Jul-07 22:19
Sam Heller15-Jul-07 22:19 
AnswerRe: Date format in cell Pin
Colin Angus Mackay15-Jul-07 23:35
Colin Angus Mackay15-Jul-07 23:35 
QuestionQuery for finding number of columns in a table? Pin
Mushtaque Nizamani15-Jul-07 20:41
Mushtaque Nizamani15-Jul-07 20:41 
AnswerRe: Query for finding number of columns in a table? Pin
RepliCrux15-Jul-07 20:59
RepliCrux15-Jul-07 20:59 
QuestionNeed help to select max date Pin
masyarial15-Jul-07 18:37
masyarial15-Jul-07 18:37 
I try this code, and it's work.

select name,date=max(date),
sum(case when type='A' then value else 0 end) as 'A',
sum(case when type='B' then value else 0 end) as 'B',
sum(case when type='C' then value else 0 end) as 'C'
from table1
group by name

But after few days, my database is update with more than one record in the same name, separate by column name 'date',
Regarding I just want to display data depend on last date,
Example my table is below:

name type value date
-----------------------------------------------------
a A 1 07/10/2007
a B 1 07/10/2007
a C 1 07/10/2007
a A 2 07/13/2007
a B 2 07/13/2007
a C 2 07/13/2007

but the result is:

the result is:
name date A B C
-----------------------------------------
a 06/13/2007 3 3 3

I'm expecting like this:
name date A B C
-----------------------------------------
a 06/13/2007 2 2 2

I try to modified the code:
select name,
sum(case when type='A' and date=max(date) then....
but found error

So, any suggestion, thanks a lot.
AnswerRe: Need help to select max date Pin
Paul Conrad15-Jul-07 18:57
professionalPaul Conrad15-Jul-07 18:57 
GeneralRe: Need help to select max date Pin
Krish - KP15-Jul-07 19:08
Krish - KP15-Jul-07 19:08 
GeneralRe: Need help to select max date Pin
Paul Conrad15-Jul-07 19:23
professionalPaul Conrad15-Jul-07 19:23 
GeneralRe: Need help to select max date Pin
Krish - KP15-Jul-07 23:25
Krish - KP15-Jul-07 23:25 
GeneralRe: Need help to select max date Pin
masyarial16-Jul-07 0:00
masyarial16-Jul-07 0:00 
GeneralRe: Need help to select max date Pin
Krish - KP16-Jul-07 1:36
Krish - KP16-Jul-07 1:36 
GeneralRe: Need help to select max date Pin
masyarial16-Jul-07 22:03
masyarial16-Jul-07 22:03 
GeneralRe: Need help to select max date Pin
masyarial15-Jul-07 20:31
masyarial15-Jul-07 20:31 
AnswerRe: Need help to select max date Pin
Krish - KP15-Jul-07 19:09
Krish - KP15-Jul-07 19:09 
GeneralRe: Need help to select max date Pin
Paul Conrad15-Jul-07 19:17
professionalPaul Conrad15-Jul-07 19:17 
GeneralRe: Need help to select max date Pin
masyarial15-Jul-07 20:55
masyarial15-Jul-07 20:55 
GeneralRe: Need help to select max date Pin
masyarial15-Jul-07 22:15
masyarial15-Jul-07 22:15 
QuestionSQL SERVER Pin
magedhv15-Jul-07 0:27
magedhv15-Jul-07 0:27 
AnswerRe: SQL SERVER Pin
Paul Conrad15-Jul-07 5:14
professionalPaul Conrad15-Jul-07 5:14 
AnswerRe: SQL SERVER Pin
sidbaruah17-Jul-07 19:08
sidbaruah17-Jul-07 19:08 
QuestionImport DB diagram in Visiso Pin
merwa14-Jul-07 22:06
merwa14-Jul-07 22:06 
AnswerRe: Import DB diagram in Visiso [modified] Pin
martin_hughes15-Jul-07 13:09
martin_hughes15-Jul-07 13:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.