Find an SQL statement ~ "

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.