How to get value greater than 0 from table in Sqlite

jon

Hye,

I have table Client

  date   idClient   nameClient      OpenBal  open Payable  dr  cr  comPay  close

2016-10-5    CL-MK  Kashif  CL-MK   9000    33134    0    5000   0      0      0   
2016-10-5    CL-MK  Kashif  CL-MK    0      33134    0    6000   0      0      0
2016-10-5    CL-MA  Asim  CL-MA    -8000    33134    0      0    0      0      0
2016-10-5    CL-MA  Asim  CL-MA      0      33134    0    7000   0      0      0
2016-10-5    CL-MA  Asim  CL-MA      0      33134    0      0    0      0      0
2016-10-5    CL-MW  Waqar  CL-MW   4000     33134    0    5000   0      0      0
2016-10-5    CL-MW  Waqar  CL-MW     0      33134    0      0    0      0      0
2016-10-5    CL-MW  Waqar  CL-MW     0      33134    0    8000   0      0      0
2016-10-5    CL-MF  Fahad   CL-MF -7000     33134    0      0    0      0      0
2016-10-5    CL-MF  Fahad   CL-MF    0      33134    0      0    0      0      0
2016-10-5    CL-MF  Fahad   CL-MF    0      33134    0   10000 20000 150000    0
2016-10-5    CL-MF  Fahad   CL-MF    0      33134    0      0    0      0      0

I used this query to sum of all client

SELECT idClient,nameMemb,min(OpenBal)as OpenBal,sum(open) as open,(min(openBal)+sum(open))as able,sum(re)as re ,sum(cr) as cr,sum(comPay)as comPay,(min(openBal)+sum(open)-sum(re)-sum(cr)+sum(comPay))as close from AddClient  WHERE strftime ('%m', date) = '10' group by nameMemb

in the result table the close column have 0 and negative velues I want to get value greater then zero..

I try this

  SELECT idClient,nameMemb,min(OpenBal)as OpenBal,sum(open) as open,(min(openBal)+sum(open))as able,sum(re)as re ,sum(cr) as cr,sum(comPay)as comPay,(min(openBal)+sum(open)-sum(re)-sum(cr)+sum(comPay))as close from AddClient  WHERE strftime ('%m', date) = '10' and close > 0 group by nameMemb

but this query not give me result.

Mike W.

I believe you need to use a having clause AFTER your group by. Something like:

SELECT 
  idClient,nameMemb,min(OpenBal)as OpenBal,sum(open) as open,(min(openBal)+sum(open))as able,sum(re)as re ,sum(cr) as cr,sum(comPay)as comPay,(min(openBal)+sum(open)-sum(re)-sum(cr)+sum(comPay))as close
from 
  AddClient  
WHERE 
  strftime ('%m', date) = '10' 
group by 
  nameMemb 
having 
  close > 0

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to count rows of pivot table where value is greater than 0

From Dev

Android sqlite query to get tables with values greater than a value

From Dev

Android sqlite query to get tables with values greater than a value

From Dev

how to make font-weight:bold ,if table tbody tr td value greater than 0 without loop

From Dev

Output with value greater than 0

From Dev

How to query a result with value greater than the min(value) of a table in Oracle

From Dev

How can I subtract a user input value from a value in a MySQL table only if the value in the field is equal to or greater than the input value?

From Dev

How to find customer with orders greater than X from single table

From Dev

How to find age greater than value from json using pyspark?

From Dev

Find minimum value greater than 0

From Dev

Getting minumum value but greater than 0

From Dev

Display Message box if value is greater than 0

From Dev

Break table if height is greater than value

From Dev

querying a collection with a value greater than 0 while keeping the current month whether the value is 0 or greater than 0

From Dev

SQLite Get value from other table

From Dev

How to get minimum positive value greater then 0 in php

From Dev

How to check if cell value is greater than X, get the difference from those 2 values and add to the next cell in Excel?

From Dev

How to delete rows in Table1 where COUNT of WHERE in Table2 is greater than 0?

From Dev

Get minimum value greater than zero

From Dev

Get minimum value greater than zero

From Dev

SQLite returning min value greater than max value

From Dev

How to get Documents less than or greater than some value in mongodb using java

From Dev

How to use numeric(0) in greater than testing?

From Dev

Android SQLite: cursor.getcount() always return greater than 0

From Dev

How to add message to message table with ID greater than 0x20000000 (bit 29 set)?

From Dev

How to add message to message table with ID greater than 0x20000000 (bit 29 set)?

From Dev

Select greater value than 0 if it exists, leave 0 if it is the only option

From Java

How to determine if JSON object has property, and that if it does is the properties value is greater than 0?

From Dev

How to find the smallest value greater than 0 in a or-tools 1-D array (python , or-tools )

Related Related

  1. 1

    How to count rows of pivot table where value is greater than 0

  2. 2

    Android sqlite query to get tables with values greater than a value

  3. 3

    Android sqlite query to get tables with values greater than a value

  4. 4

    how to make font-weight:bold ,if table tbody tr td value greater than 0 without loop

  5. 5

    Output with value greater than 0

  6. 6

    How to query a result with value greater than the min(value) of a table in Oracle

  7. 7

    How can I subtract a user input value from a value in a MySQL table only if the value in the field is equal to or greater than the input value?

  8. 8

    How to find customer with orders greater than X from single table

  9. 9

    How to find age greater than value from json using pyspark?

  10. 10

    Find minimum value greater than 0

  11. 11

    Getting minumum value but greater than 0

  12. 12

    Display Message box if value is greater than 0

  13. 13

    Break table if height is greater than value

  14. 14

    querying a collection with a value greater than 0 while keeping the current month whether the value is 0 or greater than 0

  15. 15

    SQLite Get value from other table

  16. 16

    How to get minimum positive value greater then 0 in php

  17. 17

    How to check if cell value is greater than X, get the difference from those 2 values and add to the next cell in Excel?

  18. 18

    How to delete rows in Table1 where COUNT of WHERE in Table2 is greater than 0?

  19. 19

    Get minimum value greater than zero

  20. 20

    Get minimum value greater than zero

  21. 21

    SQLite returning min value greater than max value

  22. 22

    How to get Documents less than or greater than some value in mongodb using java

  23. 23

    How to use numeric(0) in greater than testing?

  24. 24

    Android SQLite: cursor.getcount() always return greater than 0

  25. 25

    How to add message to message table with ID greater than 0x20000000 (bit 29 set)?

  26. 26

    How to add message to message table with ID greater than 0x20000000 (bit 29 set)?

  27. 27

    Select greater value than 0 if it exists, leave 0 if it is the only option

  28. 28

    How to determine if JSON object has property, and that if it does is the properties value is greater than 0?

  29. 29

    How to find the smallest value greater than 0 in a or-tools 1-D array (python , or-tools )

HotTag

Archive