Find an SQL statement ~ ''' Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061220134634201.html
I have three tables: AA. BDF BB. DBF cc. DBF
Fields in AA. DBF
Jh yc Yx yxh
Name1 ch 0.2 101.1
Fields in BB. DBF
Using jd1 jd2
Name 1 100.1 200.1
Fields in CC. DBF
JH HS
Name 1 20061011 0.3
I want to complete this query:
First, I want to add a field SK for table AA to determine whether the value of yxh in Table AA is between jd1 and jd2 in Table BB. If the value is in SK, K is written, null if not present
I have added the value of the year and month field to ComboBox.
Select a year in ComboBox.
Find K in the sk field of the AA table and the Yx> = 0.4 in the AA table and the HS> = 30% in the CC table.
How to add the sk field to the AA table? How to write the last query statement?
-- Add field sk
Alter table aa add SK varchar (4) null
Go
-- Update field sk
Update AA set Sk = 'K' from aa a, bb B where a. JB = B. Between and A. yxh between B. jd1 and B. jd2
Go
-- Query
Select * from aa a, cc B where. bytes = B. between and. SK = 'K' and. yx & gt; = 0.4 and C. HS & gt; = 0.3 and C. year and month = value in ComboBox
In Delphi, there is a date-specific control datetimepicker, which is better than ComboBox.
Select nation, YC, YX, yhx from (select AA. *, 'sk' = case when AA. yxh> = BB. jd1 and AA. yxh <= BB. jd2 then 'k', else' from AA, BB where AA. bandwidth = BB. california) XXX, CC where Yx> = 0.4 and SK = 'K' and hs> = 0.3
Select nation, YC, YX, yhx from (select AA. *, 'sk' = case when AA. yxh> = BB. jd1 and AA. yxh <= BB. jd2 then 'k', else' end from AA, BB where AA. bandwidth = BB. california) XXX, CC where Yx> = 0.4 and SK = 'K' and hs> = 0.3
Modify it. An end is missing.