Home > database >  Small white self-study VFP SQL problems posted (a)
Small white self-study VFP SQL problems posted (a)

Time:04-03

Two tables recdbf and tempyf, with grouping query some year the total number of each month, all kinds of properties,
 sele tempyf. *,; 
The sum (iif (isnull (recdbf. Date) or the at (" general ", recdbf. Nature)=0, 1)) as general,;
The sum (iif (isnull (recdbf. Date) or the at (" major ", recdbf. Nature)=0, 1)) as a major,;
The sum (iif (isnull (recdbf. Date) or the at (" big ", recdbf properties)=0, 1)) as large;
The from tempyf left outer join recdbf;
On tempyf. Yf=month (recdbf. Date) and year (date)=2001;
Group by tempyf. Yf

Question:
1,
 isnull (recdbf. Date) or the at (" general ", recdbf properties)=0 

Understand:
Determine whether there is a NULL values in the date, any return values logic 1, if no returns 0. Date of sample files without ISNULL commonly, the ISNULL () returns 0;
At (" general ", recdbf. Nature) if there is a nature, return to 1; The iif (0 or 1=0, 1) returns a value of 1? The return value is 1 if the isnull (), at () the return value is 1, the
The iif (1 or 1, 1) return values or 1?
2, if you want to query the records of 2001 in recdbf, how to operate?
 sele * from recdbf on year (date).=2001 


Recdbf table structure
Date (characters) properties (characters)
2001.03.04 general
2002.03.04 serious
2001.02.01 general
Tempyf table structure
Yf (numeric)
1
2
3
4
  •  Tags:  
  • VFP
  • Related