|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Some SQL problem in displaying data
Hi, Currently i need to display information from 1 table. This is the information of the table which contain 3 fields
Logdate ProjCode Hrs 2003-09-11 SBS 3 2003-09-11 asd 9 2003-09-11 asd 9 2003-09-12 dsa 6 2003-09-13 zxc 5 2003-09-13 cxz 2 When i add a new field using Quey: Select *, (select Sum(Hrs) from Table a where a.Logdate = b.Logdate Group by Logdate)from Table b Result: Logdate ProjCode Hrs Sum 2003-09-11 SBS 3 22 2003-09-11 asd 9 22 2003-09-11 asd 9 22 2003-09-12 dsa 6 6 2003-09-13 zxc 5 7 2003-09-13 cxz 2 7 how do i edit my query statement where i can get Result: Logdate ProjCode Hrs Sum 2003-09-11 SBS 3 22 2003-09-11 asd 9 null 2003-09-11 asd 9 null 2003-09-12 dsa 6 6 2003-09-13 zxc 5 7 2003-09-13 cxz 2 null as only display 1 sum in 1 logdate where the rest is null. |
|
#2
|
|||
|
|||
|
to produce the last table in your problem description you have to create a temp table without the sum and then update the appropriate lines with the sum
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Some SQL problem in displaying data |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|