Click here to Skip to main content
15,888,351 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL QUERY Pin
Corporal Agarn2-Apr-13 9:17
professionalCorporal Agarn2-Apr-13 9:17 
AnswerRe: SQL QUERY Pin
Richard Deeming2-Apr-13 10:40
mveRichard Deeming2-Apr-13 10:40 
Questionwhen use of index on view instead of table Pin
mhd.sbt2-Apr-13 7:01
mhd.sbt2-Apr-13 7:01 
AnswerRe: when use of index on view instead of table Pin
R. Giskard Reventlov2-Apr-13 7:11
R. Giskard Reventlov2-Apr-13 7:11 
Questionbenefit of cluster index on view in sql 2008 r2 Pin
mhd.sbt2-Apr-13 1:45
mhd.sbt2-Apr-13 1:45 
AnswerRe: benefit of cluster index on view in sql 2008 r2 Pin
Simon_Whale2-Apr-13 1:56
Simon_Whale2-Apr-13 1:56 
GeneralRe: benefit of cluster index on view in sql 2008 r2 Pin
mhd.sbt2-Apr-13 5:16
mhd.sbt2-Apr-13 5:16 
QuestionDifference in Sum(column) between two tables Pin
Richard.Berry1001-Apr-13 3:45
Richard.Berry1001-Apr-13 3:45 
Hi
Using Microsoft.ACE.OLEDB.12.0 to access an MS Access 2007 database from a VB.net (2010) project.

SQL
SELECT tStk.WH + ' - ' + tStk.StockCode as [WP], sum(tStk.Qty) as [StkTot],  IIF(tHst.HstTot is null,0, tHst.HstTot) AS [HstTot], sum(tStk.Qty)  -  IIF(tHst.HstTot is null,0, tHst.HstTot) AS [Difference]
FROM stock_qty AS tStk
LEFT JOIN (SELECT stock_history.Location + ' - ' + stock_history.StockCode AS [WP], sum(stock_history.Qty) as [HstTot]
FROM stock_history 
GROUP BY stock_history.Location+ ' - ' + stock_history.StockCode) AS [tHst] ON  tStk.WH + ' - ' + tStk.StockCode =tHst.WP
WHERE tStk.[difference] <> 0
GROUP BY tStk.WH+ ' - ' + tStk.StockCode ,  tHst.HstTot


I only want rows where the sum of the item qty is Different in the two tables

The line:
SQL
WHERE tStk.[difference] <> 0
does not work. If I run the query from MS Access, it is asking for a value for the parameter tStk.[difference]
I also tried
SQL
WHERE sum(tStk.Qty) <> tHST.Qty
but aggregate functions are not allowed in a WHERE clause.
AnswerRe: Difference in Sum(column) between two tables Pin
David Mujica1-Apr-13 4:12
David Mujica1-Apr-13 4:12 
GeneralRe: Difference in Sum(column) between two tables Pin
Richard.Berry1004-Apr-13 8:05
Richard.Berry1004-Apr-13 8:05 
AnswerRe: Difference in Sum(column) between two tables Pin
Jörgen Andersson1-Apr-13 8:21
professionalJörgen Andersson1-Apr-13 8:21 
GeneralRe: Difference in Sum(column) between two tables Pin
Richard.Berry1004-Apr-13 7:34
Richard.Berry1004-Apr-13 7:34 
Question2pc in SQL server Pin
Soiraian31-Mar-13 6:21
Soiraian31-Mar-13 6:21 
AnswerRe: 2pc in SQL server Pin
RedDk31-Mar-13 7:44
RedDk31-Mar-13 7:44 
QuestionViews vs Tables Pin
Eric Whitmore29-Mar-13 4:50
Eric Whitmore29-Mar-13 4:50 
AnswerRe: Views vs Tables Pin
PIEBALDconsult29-Mar-13 5:37
mvePIEBALDconsult29-Mar-13 5:37 
GeneralRe: Views vs Tables Pin
Eric Whitmore29-Mar-13 5:47
Eric Whitmore29-Mar-13 5:47 
GeneralRe: Views vs Tables Pin
PIEBALDconsult29-Mar-13 6:21
mvePIEBALDconsult29-Mar-13 6:21 
GeneralRe: Views vs Tables Pin
GuyThiebaut30-Mar-13 5:29
professionalGuyThiebaut30-Mar-13 5:29 
GeneralRe: Views vs Tables Pin
PIEBALDconsult30-Mar-13 5:51
mvePIEBALDconsult30-Mar-13 5:51 
GeneralRe: Views vs Tables Pin
GuyThiebaut30-Mar-13 5:57
professionalGuyThiebaut30-Mar-13 5:57 
GeneralRe: Views vs Tables Pin
jschell30-Mar-13 12:46
jschell30-Mar-13 12:46 
GeneralRe: Views vs Tables Pin
GuyThiebaut30-Mar-13 20:37
professionalGuyThiebaut30-Mar-13 20:37 
GeneralRe: Views vs Tables Pin
jschell31-Mar-13 11:31
jschell31-Mar-13 11:31 
GeneralRe: Views vs Tables Pin
jschell30-Mar-13 12:45
jschell30-Mar-13 12:45 

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.